unemployment {asuR} | R Documentation |
Data set with success (long term) unemployment against total number o unemployment.
data(unemployment)
A data frame with 983 observations on the following 2 variables.
success
<6m
>6m
gender
female
male
no
GLM course notes by Gerhard Tutz (have a look at his nice book!)
data(unemployment) contrast.matrix <- rbind("male-female"=c(1,-1)) u.glm <- glm(success~gender, data=unemployment, family=binomial, contrasts=list(gender=mycontr(contrast.matrix))) ### for data in the grouped form ################################# ### we make a data set in grouped form table(unemployment$gender, unemployment$success) unemployment.grouped <- data.frame(longterm=c(167,175), shortterm=c(403,238), gender=c("male","female")) u.glm.grouped <- glm(cbind(longterm,shortterm) ~ gender, data=unemployment.grouped, family=binomial, contrasts=list(gender=mycontr(contrast.matrix))) summary(u.glm.grouped) coefficients(u.glm.grouped) ### extracting the factors by which the odds change from male to female factor <- exp(coefficients(u.glm.grouped)[2]) ### the "same" calculations by hand: attach(unemployment.grouped) p <- longterm/(shortterm+longterm) detach(unemployment.grouped) odds <- p/(1-p) odds[1]*factor ### should give the same as odds[2] ### for those who like p-values ################################# anova(u.glm, test="Chisq") ### is the same anova(u.glm.grouped,test="Chisq") ### the same p-value pchisq(17.959,1,lower.tail=FALSE) ### and also almost the same p-value as with a chisq.test()...that you ### can try yourself!