Dref {gnm} | R Documentation |
A function to provide the objects and functions required to fit a diagonal
reference term in a generalized nonlinear model using gnm
.
Dref(..., formula = ~ 1)
... |
a comma-separated list of two or more factors. |
formula |
a symbolic description of the model for each factor weight. |
Designed to work as a plug-in function for gnm
, Dref
produces
the objects required to fit diagonal reference terms as introduced by
Sobel (1981, 1985). Such terms comprise an additive component for
each factor of the form
w_f gamma_l
where w_f is the weight for factor f, gamma_l is the diagonal effect for level l and l is the level of factor f for the given data point.
The weights are constrained to be nonnegative and to sum to one as follows
w_f = exp(delta_f)/sum_i(exp(delta_i))
and the delta_f are modelled as specified by the
formula
argument (constant weights by default). The
returned parameters are those in the model for
delta_f, rather than the implied weights w_f.
To specify a diagonal reference term in the formula argument to gnm
,
the symbolic wrapper Nonlin
must be used, with a call to Dref
as the first argument.
If the factors passed to Dref
do not have exactly the same
levels, the set of levels in the diagonal reference term is taken to
be the union of the factor levels, sorted into increasing order.
A list with the anticipated components of a gnm
plug-in
function:
start |
a vector of starting values for the parameters in the diagonal reference term. |
labels |
a character vector of labels for the parameters in the diagonal reference term. |
predictor |
a function that takes estimates of the parameters in the diagonal reference term and returns a matrix whose columns are the fitted additive components of this term. |
localDesignFunction |
a function that takes the result of the predictor function and returns the local design matrix. |
Heather Turner
Sobel, M. E. (1981), Diagonal mobility models: A substantively motivated class of designs for the analysis of mobility effects. American Sociological Review 46, 893–906.
Sobel, M. E. (1985), Social mobility and fertility revisited: Some new models for the analysis of the mobility effects hypothesis. American Sociological Review 50, 699–712.
Clifford, P. and Heath, A. F. (1993) The Political Consequences of Social Mobility. J. Roy. Stat. Soc. A, 156(1), 51-61.
Van der Slik, F. W. P., De Graaf, N. D and Gerris, J. R. M. (2002) Conformity to Parental Rules: Asymmetric Influences of Father's and Mother's Levels of Education. European Sociological Review 18(4), 489 – 502.
MultHomog
for another gnm
plug-in function.
Mult
for specifying multiplicative interactions
in gnm
formulae.
### Examples from Clifford and Heath paper ### (Results differ slightly - 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 ~ -1 + Nonlin(Dref(origin, destination)), family = binomial, data = voting) prop.table(exp(coef(classMobility)[1:2])) ## 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 + Nonlin(Dref(origin, destination, formula = ~ 1 + downward + upward)), family = binomial, data = voting) coefs <- coef(socialMobility) baseline <- coefs[pickCoef(socialMobility, "(Intercept)")] upwardTRUE <- coefs[pickCoef(socialMobility, "upwardTRUE")] downwardTRUE <- coefs[pickCoef(socialMobility, "downwardTRUE")] prop.table(exp(baseline)) prop.table(exp(upwardTRUE + baseline)) prop.table(exp(downwardTRUE + baseline)) ## fit separate weights for downwardly mobile groups only downwardMobility <- gnm(yvar ~ -1 + Nonlin(Dref(origin, destination, formula = ~ 1 + downward)), family = binomial, data = voting) downwardMobility coefs <- coef(downwardMobility) baseline <- coefs[pickCoef(downwardMobility, "(Intercept)")] downwardTRUE <- coefs[pickCoef(downwardMobility, "downwardTRUE")] prop.table(exp(baseline)) prop.table(exp(downwardTRUE + baseline)) ## Not run: ### 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 + Nonlin(Dref(MOPLM, FOPLF)), family = gaussian, data = conformity, verbose = FALSE) A ## Call: ## gnm(formula = MCFM ~ -1 + AGEM + MRMM + FRMF + MWORK + MFCM + ## Nonlin(Dref(MOPLM, FOPLF)), family = gaussian, data = conformity, ## verbose = FALSE) ## ## ## Coefficients: ## AGEM MRMM FRMF ## 0.06364 -0.32425 -0.25324 ## MWORK MFCM Dref(MOPLM, FOPLF).MOPLM ## -0.06430 -0.06043 0.34389 ## Dref(MOPLM, FOPLF).FOPLF Dref(MOPLM, FOPLF).1 Dref(MOPLM, FOPLF).2 ## 0.65611 4.95123 4.86328 ## Dref(MOPLM, FOPLF).3 Dref(MOPLM, FOPLF).4 Dref(MOPLM, FOPLF).5 ## 4.86458 4.72342 4.43516 ## Dref(MOPLM, FOPLF).6 Dref(MOPLM, FOPLF).7 ## 4.18873 4.43379 ## ## Deviance: 425.3389 ## Pearson chi-squared: 425.3389 ## Residual df: 576 prop.table(exp(coef(A)[pickCoef(A, "[.]MOPLM|[.]FOPLF")])) ## weights as in Table 4 ## Dref(MOPLM, FOPLF).MOPLM Dref(MOPLM, FOPLF).FOPLF ## 0.4225734 0.5774266 F <- gnm(MCFM ~ -1 + AGEM + MRMM + FRMF + MWORK + MFCM + Nonlin(Dref(MOPLM, FOPLF, formula = ~1 + MFCM)), family = gaussian, data = conformity, verbose = FALSE) F ## Call: ## gnm(formula = MCFM ~ -1 + AGEM + MRMM + FRMF + MWORK + MFCM + ## Nonlin(Dref(MOPLM, FOPLF, formula = ~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, formula = ~1 + MFCM).MOPLM.(Intercept) ## 1.03516 ## Dref(MOPLM, FOPLF, formula = ~1 + MFCM).MOPLM.MFCM ## -1.77703 ## Dref(MOPLM, FOPLF, formula = ~1 + MFCM).FOPLF.(Intercept) ## -0.03516 ## Dref(MOPLM, FOPLF, formula = ~1 + MFCM).FOPLF.MFCM ## 2.77703 ## Dref(MOPLM, FOPLF, formula = ~1 + MFCM).1 ## 4.82477 ## Dref(MOPLM, FOPLF, formula = ~1 + MFCM).2 ## 4.88066 ## Dref(MOPLM, FOPLF, formula = ~1 + MFCM).3 ## 4.83969 ## Dref(MOPLM, FOPLF, formula = ~1 + MFCM).4 ## 4.74849 ## Dref(MOPLM, FOPLF, formula = ~1 + MFCM).5 ## 4.42019 ## Dref(MOPLM, FOPLF, formula = ~1 + MFCM).6 ## 4.17956 ## Dref(MOPLM, FOPLF, formula = ~1 + MFCM).7 ## 4.40819 ## ## Deviance: 420.9022 ## Pearson chi-squared: 420.9022 ## Residual df: 575 baseline <- coef(F)[pickCoef(F, "(Intercept)")] prop.table(exp(baseline)) ## weights for MFCM = 0 ## Dref(MOPLM, FOPLF, formula = ~1 + MFCM).MOPLM.(Intercept) ## 0.7446585 ## Dref(MOPLM, FOPLF, formula = ~1 + MFCM).FOPLF.(Intercept) ## 0.2553415 MFCM1 <- coef(F)[pickCoef(F, "[.]MFCM")] prop.table(exp(MFCM1 + baseline)) ## weights for MFCM = 1 ## Dref(MOPLM, FOPLF, formula = ~1 + MFCM).MOPLM.MFCM ## 0.02977851 ## Dref(MOPLM, FOPLF, formula = ~1 + MFCM).FOPLF.MFCM ## 0.97022149 ## End(Not run)