### (Results differ slightly from paper - possible transcription error in
### published data?)
set.seed(1)
data(voting)
## reconstruct counts voting Labour/non-Labour
count <- with(voting, percentage/100 * total)
yvar <- cbind(count, voting$total - count)
## fit diagonal reference model with constant weights
classMobility <- gnm(yvar ~ Nonlin(Dref(origin, destination)),
family = binomial, data = voting)
prop.table(exp(coef(classMobility)[2:3]))
## create factors indicating movement in and out of salariat (class 1)
upward <- with(voting, origin != 1 & destination == 1)
downward <- with(voting, origin == 1 & destination != 1)
## fit separate weights for the "socially mobile" groups
socialMobility <- gnm(yvar ~ Nonlin(Dref(origin, destination,
formula = ~ 1 + downward + upward)),
family = binomial, data = voting)
prop.table(exp(coef(socialMobility)[c(4, 7)] + coef(socialMobility)[c(2, 5)]))
prop.table(exp(coef(socialMobility)[c(3, 6)] + coef(socialMobility)[c(2, 5)]))
prop.table(exp(coef(socialMobility)[c(2, 5)]))
## fit separate weights for downwardly mobile groups only
downwardMobility <- gnm(yvar ~ Nonlin(Dref(origin, destination,
formula = ~ 1 + downward)),
family = binomial, data = voting)
downwardMobility
prop.table(exp(coef(downwardMobility)[c(3, 5)] +
coef(downwardMobility)[c(2, 4)]))
prop.table(exp(coef(downwardMobility)[c(2, 4)]))
Run the code above in your browser using DataLab