Stata macros for multinomial conditional logit models
MCL stands for Multinomial Conditional Logit model. A conditional logit program is used to estimate a multinomial logistic model. This produces the same coefficients and standard errors as a regular multinomial logit program but has the advantage that it provides great flexibility for imposing constraints on the dependent variable. mclgen restructures the data so the model can be estimated by clogit, mclest estimates the model using clogit.
In addition, mclest can estimate two special models: stereotyped ordered regression (SOR) and Goodman's row and columns model 2 (RC2). Both models estimate a scaling metric for the dependent variable; the RC2 model estimates a scaling metric for a categorical independent variable as well.
Syntax:
mclest varlist [if exp] [in range] [weight] [, sor(varlist) soriter(#) sortol(#) rc2(varname) eqrc2(varname) muby(varlist) nonorm debug ]
varlist contains a model specification. The main effects of the response factor specified in mclgen correspond with the intercept in a multinomial logit model. Interactions of the response factor with independent variables correspond with the effects of these variables. Because the response factor is on the right hand side of the model specification, it is a simple matter to impose restrictions. The dichotomous dependent variable and the stratification variable are automically passed on from mclgen to mclest and do not have to be specified.
Options
These options are used to request the special nonlinear models Sterotyped Ordered Regression (SOR) and/or the Row and Columns model 2 (RC2).
sor(varlist) specifies a list of variables for which the SOR model should be estimated. Note that at least two variables should be specified, unless either the rc2 or eqrc2 option is being used.
soriter(#) specifies the maximum number of iterations for estimating a SOR or RC2 model. The default value is 20.
sortol(#) specifies the convergence criterion for estimating a SOR or RC2 model. The default value is .0001.
rc2(varname) specifies a categorical independent variable for the RC2 model. The eqrc2 option will be ignored if the rc2 option is specified.
eqrc2(varname) specifies a categorical independent variable for the EQRC2 model. The rc2 option may not be used together with the eqrc2 option.
muby(varlist) specifies one or more variables which affect the association between the rc2 or eqrc2 variable and the dependent variable. Ignored if not used in conjunction with the rc2 or eqrc2 option.
nonorm prevents the mclest program from estimating a normalized solution if a SOR and/or RC2 model has been requested.
debug prints intermediate results of clogit. This can be used to determine the source of error if something goes wrong. The default is nodebug.
mclest passes the following arguments on to clogit unaltered:
weight, if, in
See the Stata documentation on clogit for further details on these options.
Usage
For basic use, mclest will be specified with a list of dummy variables representing the main effects of the response factor and interactions of the response factor with independent variables.
The main effects of the independent variables should not be specified; unfortunately xi does not provide this option. As a result, clogit will report that the main effects have been "omitted due to no within-group variance". This has no further consquences for the estimates.
In the following example, the variable occ (respondent's occupation, 5 categories) is the response factor. It is specified in the mclgen command to transform the data into a person/choice file. mclgen reports "(3352 observations created)", each of the 838 cases has been duplicated 4 times so that there are now 5 records for each respondent. The cases are indexed by occ and __strata. occ indicates response options 1 to 5, __strata indicates respondents 1 to 838. The variable __didep indicates which record corresponds with the respondent's choice.
The model is specified as a main effect of occ and interactions of occ with the independent variables educ and black. The model could be specified as xi: mclest i.occ*educ i.occ*black instead. This produces the same estimates but a different order of the estimates.
* Using mcl to estimate a multinomial logit model use logan
mlogit occ educ black, base(1)
mclgen occ xi: mclest i.occ i.occ|educ i.occ|black
The coefficients of this model are the same as those found using mlogit. For models like this, mclest basicly just specifies the __didep and __strata variables for you in a clogit command. The model could also be estimated as:
xi: clogit __didep i.occ i.occ|educ i.occ|black, strata(__strata)
This model can be estimated equivalently (and more easily) with mlogit. The advantage of mcl models lies in the ability to easily specify different response functions for different independent variables. A response function refers to the type of parameterization applied to the response factor.
Using xi, the first category of occ is treated as the reference category. In that case, the model is equivalent to using mlogit ..., base(1). Using xi3 or desmat, other paramterizations, or contrasts, can be applied to the response factor, obtaining other response functions. Equality constraints can be imposed on two categories of the response factor by adding the dummies for those two categories. A parameter can be fixed to zero by dropping the dummy for that cateory. A linear constraint can be imposed by treating the response factor as a continuous variable. In an mcl model, such restrictions can be imposed on the indendent variables on a variable by variable basis.
For example, to estimate an adjacent logit (Agresti 1990: 318) model with mclest, use the backward difference contrast with either xi3 or desmat. Both xi3 and desmat are available from the ssc archives. To estimate and adjacent logit model with xi3, use:
xi3: mclest b.occ b.occ*educ b.occ*black
Or with desmat:
char occ[pzat] dif(b) desmat: mclest occ occ.@educ occ.@black
Another conceivable application might be to impose a linear constraint on the response factor for the effects of educ but to use the usual constraints (first category is reference) for black. This could be done as follows:
gen occ_ed=occ*educ xi: mclest i.occ occ_ed i.occ*black
Mobility models
With mclest, it is easy to impose any constraint you might wish on the response factor and to impose a different constraint for each independent (dummy) variable if necessary. One application of this is to specify loglinear model for square tables, also known as mobility models, as multinomial logistic models (cf. Logan 1983, Breen 1994).
Mobility models lie in the space between a model of independence and a saturated loglinear model. Special constraints are imposed on the second degree loglinear parameters in order to test for a particular pattern of association and to enhance interpretablity by reducing the number of parameters. Hout (1983) and Goodman (1984) contain overviews of commonly used mobility models.
When treated as multinomial logit models, mobility models utilize a different response function, i.e. a different set of restrictions on the response factor, for different levels of the "other" variable. For example, in a quasi-independence model for father's occupation by son's occupation, son's occupation would be specified as the response factor. For category i of father's occupation, the response function would be category i of son's occupation versus the other categories. The model would be specified as:
mclgen occ gen d1=(focc==1)*(occ==1) gen d2=(focc==2)*(occ==2) gen d3=(focc==3)*(occ==3) gen d4=(focc==4)*(occ==4) gen d5=(focc==5)*(occ==5) xi: mclest i.occ d* i.occ|black i.occ|educ
The specification (occ==i) represents the reponse function for a particular dummy variable. This dummy variable will produce the logit of landing in category i versus some other category. So d1 indicates the effect of father's occupation being equal to 1 on the logit for the son being in category 1 versus some other category.
As it turns out, once the data have been transformed into a person choice file, mobility models can be specified in an mcl model in the same way they would be in a loglinear model. So the much more compact specification:
gen diag=(focc==occ)*focc xi: mclest i.occ i.diag i.occ|black i.occ|educ
Could be used as well. Examples for estimating a number of mobility models are in the file mobility.do in the desmat package. Use net get desmat to download these ancillary files
Stereotyped Ordered Regression
mclest is also able to estimate certain special designs incorporating both linear and multiplicative effects. One of these is the Stereotyped Ordered Regression model (Anderson 1984, DiPrete 1990). The SOR model is an alternative to the proportional odds model estimated by ologit. The SOR model estimates a scaling metric for the response factor based on the effects of independent variables. The model has J-1 intercept parameters for a response factor with J categories, just like an unordered multinomial logit model. However, it has a single beta parameter for each independent variable, together with J-2 independent scale values phi[j] for the response factor.
Two restrictions must be placed on the scaling metric in order to identify the model. mclest sets the value for the first category to 0 and the value for the last category to 1 while estimating the model. For the final estimates, the scaling metric is also normalized, with a mean of 0 and a sum of squares of 1.
The SOR model can be specified as:
log(P(Y==q)/P(Y==r)) = a[q]-a[r] + (phi[q]-phi[r])(b[1]X[1]+b[2]X[2]+ ... +b[K]X[K])
Where Y is the response factor with categories j=1 to J, q and r are any two categories of Y, a[j] represents the intercept parameters with suitable restrictions, phi[j] represents the scaling metric with suitable restrictions, X[k] represents independent variables with k=1 to K, and b[k] represents parameters of the independent variables.
Compare this to a standard multinomial logistic model:
log(P(Y==q)/P(Y==r)) = a[q]-a[r] + (b[q1]-b[r1])X[1]+(b[q2]-b[r2])X[2]+ ... +(b[qK]-b[rK])X[K])
In a multinomial model, the difference between b[qk] and b[rk] show how the logit(q/r) is affected by X[k]. In the SOR model, the degree of this effect equals (phi[q]-phi[r])b[k]X[k]. The SOR model forces the effect on the logit for any two outcomes to be proportional for all independent variables, with the magnitude of the effect being determined by the b[k] parameters.
A SOR model can be requested by specifying a varlist in the sor option. A SOR model with only one X[k] variable would be trivial and equivalent to standard multinomial model since it contains the same number of parameters. A simple SOR model with two variables could be specified as:
use logan mclgen occ
xi: mclest i.occ, sor(educ black)
This model will contain 9 parameters: 4 intercept parameters, 3 independent phi[j] parameters, and 2 b[k] parameters. This is only slightly 3 less than for an unrestricted multinomial model. However, the parsimony of a SOR model does increase as the number of X[k] variables increase.
The SOR model contains both linear and multiplicative elements. To estimate it, mclest iteratively estimates MCL models, first taking the phi[j] scaling metric as given and estimating the b[k] parameters, then taking the b[k] parameters as given and estimating the phi[j] parameters. This continues until the change in log likelihood between successive MCL models is less than the value specified in the sortol option (defalut .0001) or the maximum number of iterations specified in the soriter option is exceeded (default 20).
As a result of this estimation procedure, no standard errors can be given for the phi[j] parameters and standard errors for the remaining parameters are conditional, given the scaling metric. In addition, the model degrees of freedom reported by clogit are not correct since the estimates for the scaling metric are not taken into account. See the Model fit information at the end of the output for the correct number of degrees of freedom. e(df_m) in the saved results also contains the correct degrees of freedom.
Row and Columns model 2
A second special model that can be estimated by mclest is Goodman's (1979) Row and Columns model 2. Originally developed for frequency tables, the RC2 model estimates scaling metrics for both the dependent variable and one of the independent variables. The association between the two variables can then be expressed through a single parameter mu. The scaling metric for the dependent variable is phi[j] as in the SOR model, the scaling metric for the independent variable is sigma[v]. Two restrictions must be imposed on phi[j] and sigma[v] to identify the model. During estimation, mclest sets phi[1]=sigma[1]=0 and phi[J]=sigma[V]=1. The final estimates are also given for normalized scale values, where mean(phi[j])=mean(sigma[v])=0 and SS(phi[j])=SS(sigma[v])=1.
A model containing an RC2 effect could be specified as:
logit(q/r) = a[q]-a[r] + (phi[q]-phi[r])mu*sigma[v]
This model can be extended with standard and/or SOR effectsof independent variables. Indeed, the RC2 effects can be seen as the SOR effects of a categorical variable, scaled by mu*sigma[v].
A variation of the RC2 model is the EQual Row and Columns model 2 (EQRC2), which as the name suggests uses the same scale for the dependent variable and the categorical independent.
logit(q/r) = a[q]-a[r] + (phi[q]-phi[r])mu*phi[v]
Another variation implemented in mclest allows the association mu between the dependent and independent variable to vary by one or more other variables.
logit(q/r) = a[q]-a[r] + (phi[q]-phi[r])(mu[0]+mu[t]X[t])*phi[v]
An overall association parameter mu[0] is estimated, together with mu[t] parameters indicating how the association changes for each independent variable X[t], t=1 to T.
An RC2 model is requested by specifying a varname in the rc2 option. At present, only one variable can be used for the RC2 effect. Similarly, an EQRC2 model can be requested by specifying a varname in the eqrc2 option. The rc2 and eqrc2 options are mutually exclusive. To let the overall association vary by one or more independent variables, specify a varlist in the muby option.
The following example estimates a quasi RC2 model for father's occupation, including both effects for identical categories (diag) and an rc2 effect. The overall association mu between father's occupation and respondent's occupation is allowed to vary by race. Further more, race and education are included in the model as covariates using a SOR effect.
use logan mclgen occ
gen diag=(focc==occ)*focc xi: mclest i.occ i.diag, sor(educ black) rc2(focc) muby(black)
Models containing RC2 or EQRC2 effects are estimated by iteratively running MCL models, as is the case for SOR models. Convergence criterion and maximum iterations are determined by the sortol and soriter options. As with SOR models, no standard errors are available for the sigma[v] metric and other standard errors are conditional on the phi[j] and sigma[v] estimates. See the Model fit information at the end of the output for the correct number of model degrees of freedom.
For tabular data, a separate rc2 program is also available from the ssc archives. Note that mclest can estimate these models in many cases. The differences are that mclest will not estimate the main effects of the row variable and that interactions between the row variable and a grouping variable must be included in rc2 for the models to be equivalent. An advantage of rc2 is that it does not require a restructuring of the data by mclgen.
Saved results
In addition to the results saved by clogit, mclest saves the following matrices:
e(phi) the phi scale with the first category fixed to 0, the last to 1
e(phi_n) the phi scale with mean 0 and sum of squares 1
e(df_m) the model degrees of freedom adjusted for the sigma and phi parameters
If the rc2 or eqrc2 option has been used, mclest also saves:
e(sig) the sigma scale with the first category fixed to 0, the last to 1
e(sig_n) the sigma scale with mean 0 and sum of squares 1
References
Anderson, J.A. (1984). Regression and Ordered Categorical Variables. Journal of the Royal Statistical Society, Series B 46: 1-30.
Breen, Richard. (1994). Individual Level Models for Mobility Tables and Other Cross-Classifications. Sociological Methods & Research 33: 147-173.
DiPrete, Thomas A. (1990). Adding Covariates to Loglinear Models for the Study of Social Mobility. American Sociological Review 55: 757-773.
Goodman, Leo A. (1979). Multiplicative models for the analysis of occupational mobility tables and other kinds of cross-classification tables. American Journal of Sociology 84: 804-819.
Hendrickx, John, Ganzeboom, Harry B.G. (1998). Occupational Status Attainment in the Netherlands, 1920-1990. A Multinomial Logistic Analysis. European Sociological Review 14: 387-403.
Hout, Michael. (1983). Mobility Tables. Sage Publication 07-031.
Logan, John A. (1983). A Multivariate Model for Mobility Tables. American Journal of Sociology 89: 324-349.
Xie, Yu (2003). Association Model. In the Encyclopedia of Social Science Research Methods, edited by Michael Lewis-Beck, Alan Bryman and Tim Futing Liao. Thousand Oaks, Ca: Sage (2003).
http://www-personal.umich.edu/~yuxie/Research/Assoc-program.html
Direct comments to: John Hendrickx
mclest is available at SSC-IDEAS. Use ssc install mcl to obtain the latest version.
The packages rc2, desmat, xi3, are also available from the ssc archives.
Also see On-line: help for mclgen, clogit, mlogit, ologit desmat, desrep, xi, xi3, rc2