### Examples from Clifford and Heath paper
### (Results differ slightly - possible transcription error in
### published data?)
set.seed(1)
## 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 ~ -1 + Dref(origin, destination),
family = binomial, data = voting)
DrefWeights(classMobility)
## 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 ~ -1 + Dref(origin, destination,
delta = ~ 1 + downward + upward),
family = binomial, data = voting)
DrefWeights(socialMobility)
## fit separate weights for downwardly mobile groups only
downwardMobility <- gnm(yvar ~ -1 + Dref(origin, destination,
delta = ~ 1 + downward),
family = binomial, data = voting)
DrefWeights(downwardMobility)
if (FALSE) {
### Examples from Van der Slik paper
### For illustration only - data not publically available
### Using data in data.frame named 'conformity', with variables
### MCFM - mother's conformity score
### FCFF - father's conformity score
### MOPLM - a factor describing the mother's education with 7 levels
### FOPLF - a factor describing the father's education with 7 levels
### AGEM - mother's birth cohort
### MRMM - mother's traditional role model
### FRMF - father's traditional role model
### MWORK - mother's employment
### MFCM - mother's family conflict score
### FFCF - father's family conflict score
set.seed(1)
## Models for mothers' conformity score as specified in Figure 1
A <- gnm(MCFM ~ -1 + AGEM + MRMM + FRMF + MWORK + MFCM +
Dref(MOPLM, FOPLF), family = gaussian, data = conformity,
verbose = FALSE)
A
## Call:
## gnm(formula = MCFM ~ -1 + AGEM + MRMM + FRMF + MWORK + MFCM +
## Dref(MOPLM, FOPLF), family = gaussian, data = conformity,
## verbose = FALSE)
##
## Coefficients:
## AGEM MRMM
## 0.06363 -0.32425
## FRMF MWORK
## -0.25324 -0.06430
## MFCM Dref(MOPLM, FOPLF)delta1
## -0.06043 -0.33731
## Dref(MOPLM, FOPLF)delta2 Dref(., .).MOPLM|FOPLF1
## -0.02505 4.95121
## Dref(., .).MOPLM|FOPLF2 Dref(., .).MOPLM|FOPLF3
## 4.86329 4.86458
## Dref(., .).MOPLM|FOPLF4 Dref(., .).MOPLM|FOPLF5
## 4.72343 4.43516
## Dref(., .).MOPLM|FOPLF6 Dref(., .).MOPLM|FOPLF7
## 4.18873 4.43378
##
## Deviance: 425.3389
## Pearson chi-squared: 425.3389
## Residual df: 576
## Weights as in Table 4
DrefWeights(A)
## Refitting with parameters of first Dref weight constrained to zero
## $MOPLM
## weight se
## 0.4225636 0.1439829
##
## $FOPLF
## weight se
## 0.5774364 0.1439829
F <- gnm(MCFM ~ -1 + AGEM + MRMM + FRMF + MWORK + MFCM +
Dref(MOPLM, FOPLF, delta = ~1 + MFCM), family = gaussian,
data = conformity, verbose = FALSE)
F
## Call:
## gnm(formula = MCFM ~ -1 + AGEM + MRMM + FRMF + MWORK + MFCM +
## Dref(MOPLM, FOPLF, delta = ~1 + MFCM), family = gaussian,
## data = conformity, verbose = FALSE)
##
##
## Coefficients:
## AGEM
## 0.05818
## MRMM
## -0.32701
## FRMF
## -0.25772
## MWORK
## -0.07847
## MFCM
## -0.01694
## Dref(MOPLM, FOPLF, delta = ~ . + MFCM).delta1(Intercept)
## 1.03515
## Dref(MOPLM, FOPLF, delta = ~ 1 + .).delta1MFCM
## -1.77756
## Dref(MOPLM, FOPLF, delta = ~ . + MFCM).delta2(Intercept)
## -0.03515
## Dref(MOPLM, FOPLF, delta = ~ 1 + .).delta2MFCM
## 2.77756
## Dref(., ., delta = ~ 1 + MFCM).MOPLM|FOPLF1
## 4.82476
## Dref(., ., delta = ~ 1 + MFCM).MOPLM|FOPLF2
## 4.88066
## Dref(., ., delta = ~ 1 + MFCM).MOPLM|FOPLF3
## 4.83969
## Dref(., ., delta = ~ 1 + MFCM).MOPLM|FOPLF4
## 4.74850
## Dref(., ., delta = ~ 1 + MFCM).MOPLM|FOPLF5
## 4.42020
## Dref(., ., delta = ~ 1 + MFCM).MOPLM|FOPLF6
## 4.17957
## Dref(., ., delta = ~ 1 + MFCM).MOPLM|FOPLF7
## 4.40819
##
## Deviance: 420.9022
## Pearson chi-squared: 420.9022
## Residual df: 575
##
##
## Standard error for MFCM == 1 lower than reported by Van der Slik et al
DrefWeights(F)
## Refitting with parameters of first Dref weight constrained to zero
## $MOPLM
## MFCM weight se
## 1 1 0.02974675 0.2277711
## 2 0 0.74465224 0.2006916
##
## $FOPLF
## MFCM weight se
## 1 1 0.9702532 0.2277711
## 2 0 0.2553478 0.2006916
}
Run the code above in your browser using DataLab