Stata 15 help for mixed postestimation

[ME] mixed postestimation -- Postestimation tools for mixed

Postestimation commands

The following postestimation commands are of special interest after mixed:

Command Description ------------------------------------------------------------------------- estat df calculate and display degrees of freedom for fixed effects estat group summarize the composition of the nested groups estat icc estimate intraclass correlations estat recovariance display the estimated random-effects covariance matrices estat sd display variance components as standard deviations and correlations estat wcorrelation display model-implied within-cluster correlations and standard deviations -------------------------------------------------------------------------

The following standard postestimation commands are also available:

Command Description ------------------------------------------------------------------------- contrast contrasts and ANOVA-style joint tests of estimates estat ic Akaike's and Schwarz's Bayesian information criteria (AIC and BIC) estat summarize summary statistics for the estimation sample estat vce variance-covariance matrix of the estimators (VCE) estimates cataloging estimation results hausman Hausman's specification test lincom point estimates, standard errors, testing, and inference for linear combinations of coefficients lrtest likelihood-ratio test margins marginal means, predictive margins, marginal effects, and average marginal effects marginsplot graph the results from margins (profile plots, interaction plots, etc.) nlcom point estimates, standard errors, testing, and inference for nonlinear combinations of coefficients predict predictions, residuals, influence statistics, and other diagnostic measures predictnl point estimates, standard errors, testing, and inference for generalized predictions pwcompare pairwise comparisons of estimates test Wald tests of simple and composite linear hypotheses testnl Wald tests of nonlinear hypotheses -------------------------------------------------------------------------

Syntax for predict

Syntax for obtaining BLUPs of random effects and the BLUPs' standard errors

predict [type] newvarsspec [if] [in] , reffects [reses(newvarsspec) relevel(levelvar)]

Syntax for obtaining scores after ML estimation

predict [type] newvarsspec [if] [in] , scores

Syntax for obtaining other predictions

predict [type] newvar [if] [in] [, statistic relevel(levelvar)]

newvarsspec is stub* or newvarlist.

statistic Description ------------------------------------------------------------------------- Main xb linear prediction for the fixed portion of the model only; the default stdp standard error of the fixed-portion linear prediction fitted fitted values, fixed-portion linear prediction plus contributions based on predicted random effects residuals residuals, response minus fitted values * rstandard standardized residuals ------------------------------------------------------------------------- Unstarred statistics are available both in and out of sample; type predict ... if e(sample) ... if wanted only for the estimation sample. Starred statistics are calculated only for the estimation sample, even when if e(sample) is not specified.

Menu for predict

Statistics > Postestimation

Description for predict

predict creates a new variable containing predictions such as linear predictions, standard errors, fitted values, residuals, and standardized residuals.

Options for predict

+------+ ----+ Main +-------------------------------------------------------------

xb, the default, calculates the linear prediction xb based on the estimated fixed effects (coefficients) in the model. This is equivalent to fixing all random effects in the model to their theoretical mean value of 0.

stdp calculates the standard error of the linear predictor xb.

reffects calculates best linear unbiased predictions (BLUPs) of the random effects. By default, BLUPs for all random effects in the model are calculated. However, if the relevel(levelvar) option is specified, then BLUPs for only level levelvar in the model are calculated. For example, if classes are nested within schools, then typing

. predict b*, reffects relevel(school)

would produce BLUPs at the school level. You must specify q new variables, where q is the number of random-effects terms in the model (or level). However, it is much easier to just specify stub* and let Stata name the variables stub1, stub2, ..., stubq for you.

Rabe-Hesketh and Skrondal (2012, sec. 2.11.2) discuss the link between the empirical Bayes predictions and BLUPs and how these predictions are unbiased. They are unbiased when the groups associated with the random effects are expected to vary in repeated samples. If you expect the groups to be fixed in repeated samples, then these predictions are no longer unbiased.

reses(newvarsspec) calculates the standard errors of the BLUPs of the random effects. By default, standard errors for all BLUPs in the model are calculated. However, if the relevel(levelvar) option is specified, then standard errors for only level levelvar in the model are calculated; see the reffects option.

You must specify q new variables, where q is the number of random-effects terms in the model (or level). However, it is much easier to just specify stub* and let Stata name the variables stub1, stub2, ..., stubq for you. The new variables will have the same storage type as the corresponding random-effects variables.

The reffects and reses() options often generate multiple new variables at once. When this occurs, the random effects (or standard errors) contained in the generated variables correspond to the order in which the variance components are listed in the output of mixed. Still, examining the variable labels of the generated variables (with the describe command, for instance) can be useful in deciphering which variables correspond to which terms in the model.

fitted calculates fitted values, which are equal to the fixed-portion linear predictor plus contributions based on predicted random effects, or in mixed-model notation, xb + Zu. By default, the fitted values take into account random effects from all levels in the model, however, if the relevel(levelvar) option is specified, then the fitted values are fit beginning at the topmost level down to and including level levelvar. For example, if classes are nested within schools, then typing

. predict yhat_school, fitted relevel(school)

would produce school-level predictions. That is, the predictions would incorporate school-specific random effects but not those for each class nested within each school.

residuals calculates residuals, equal to the responses minus fitted values. By default, the fitted values take into account random effects from all levels in the model; however, if the relevel(levelvar) option is specified, then the fitted values are fit beginning at the topmost level down to and including level levelvar.

rstandard calculates standardized residuals, equal to the residuals multiplied by the inverse square root of the estimated error covariance matrix.

scores calculates the parameter-level scores, one for each parameter in the model including regression coefficients and variance components. The score for a parameter is the first derivative of the log likelihood (or log pseudolikelihood) with respect to that parameter. One score per highest-level group is calculated, and it is placed on the last record within that group. Scores are calculated in the estimation metric as stored in e(b).

scores is not available after restricted maximum-likelihood (REML) estimation.

relevel(levelvar) specifies the level in the model at which predictions involving random effects are to be obtained; see the options above for the specifics. levelvar is the name of the model level and is either the name of the variable describing the grouping at that level or is _all, a special designation for a group comprising all the estimation data.

Syntax for margins

margins [marginlist] [, options]

margins [marginlist] , predict(statistic ...) [options]

statistic Description ------------------------------------------------------------------------- xb linear prediction for the fixed portion of the model only; the default reffects not allowed with margins scores not allowed with margins stdp not allowed with margins fitted not allowed with margins residuals not allowed with margins rstandard not allowed with margins -------------------------------------------------------------------------

Statistics not allowed with margins are functions of stochastic quantities other than e(b).

For the full syntax, see [R] margins.

Menu for margins

Statistics > Postestimation

Description for margins

margins estimates margins of response for linear predictions.

Syntax for test and testparm

test (spec) [(spec) ...] [, test_options small]

testparm varlist [, testparm_options small]

Menu for test and testparm

Statistics > Postestimation

Description for test and testparm

test and testparm, by default, perform chi-squared tests of simple and composite linear hypotheses about the parameters for the most recently fit mixed model. They also support F tests with a small-sample adjustment for fixed effects.

Options for test and testparm

+---------+ ----+ Options +----------------------------------------------------------

test_options; see [R] test options. Options df(), common, and nosvyadjust may not be specified together with small.

testparm_options; see options of testparm in [R] test. Options df() and nosvyadjust may not be specified together with small.

small specifies that F tests for fixed effects be carried out with the denominator degrees of freedom (DDF) obtained by the same method used in the most recently fit mixed model. If option dfmethod() is not specified in the previous mixed command, option small is not allowed. For certain methods, the DDF for some tests may not be available. See Small-sample inference for fixed effects in [ME] mixed for more details.

Syntax for lincom

lincom exp [, lincom_options small]

Menu for lincom

Statistics > Postestimation

Description for lincom

lincom, by default, computes point estimates, standard errors, z statistics, p-values, and confidence intervals for linear combinations of coefficients after mixed. lincom also provides t statistics for linear combinations of the fixed effects, with the degrees of freedom calculated by the DF method specified in option dfmethod() of mixed.

Options for lincom

lincom_options; see [R] lincom options. Options df() may not be specified together with small.

small specifies that t statistics for linear combinations of fixed effects be displayed with the degrees of freedom obtained by the same method used in the most recently fit mixed model. If option dfmethod() is not specified in the previous mixed command, option small is not allowed. For certain methods, the degrees of freedom for some linear combinations may not be available. See Small-sample inference for fixed effects in [ME] mixed for more details.

Syntax for contrast

contrast termlist [, contrast_options small]

Menu for contrast

Statistics > Postestimation

Description for contrast

contrast, by default, performs chi-squared tests of linear hypotheses and forms contrasts involving factor variables and their interactions for the most recently fit mixed model. contrast also supports tests with small-sample adjustments after mixed, dfmethod().

Options for contrast

contrast_options; see [R] contrast options. Options df() and nosvyadjust may not be specified together with small.

small specifies that tests for contrasts be carried out with the DDF obtained by the same method used in the most recently fit mixed model. If option dfmethod() is not specified in the previous mixed command, option small is not allowed. For certain methods, the DDF for some contrasts may not be available. See Small-sample inference for fixed effects in [ME] mixed for more details.

Syntax for pwcompare

pwcompare marginlist [, pwcompare_options small]

Menu for pwcompare

Statistics > Postestimation

Description for pwcompare

pwcompare performs pairwise comparisons across the levels of factor variables from the most recently fit mixed model. pwcompare, by default, reports the comparisons as contrasts (differences) of margins along with z tests or confidence intervals for the pairwise comparisons. pwcompare also supports t tests with small-sample adjustments after mixed, dfmethod().

Options for pwcompare

pwcompare_options; see [R] pwcompare options. Options df() may not be specified together with small.

small specifies that t tests for pairwise comparisons be carried out with the degrees of freedom obtained by the same method used in the most recently fit mixed model with the dfmethod() option. If option dfmethod() is not specified in the previous mixed command, option small is not allowed. For certain methods, the degrees of freedom for some pairwise comparisons may not be available. See Small-sample inference for fixed effects in [ME] mixed for more details.

Examples

--------------------------------------------------------------------------- Setup . webuse pig . mixed weight week || id: week, covariance(unstructured)

Random-effects correlation matrix for level ID . estat recovariance, correlation

Display within-cluster marginal standard deviations and correlations for a cluster . estat wcorrelation, format(%4.2g)

BLUPS of random effects and standard errors of BLUPs . predict u1 u0, reffects reses(s1 s0)

--------------------------------------------------------------------------- Setup . webuse productivity, clear . mixed gsp private emp hwy water other unemp || region: || state:

Summarize composition of nested groups . estat group

Fitted values at region level . predict gsp_region, fitted relevel(region)

Log likelihood scores . predict double sc*, scores

Compute residual intraclass correlations . estat icc

--------------------------------------------------------------------------- Setup . webuse childweight, clear . mixed weight age || id: age, covariance(unstructured)

Display within-cluster correlations for the first cluster . estat wcorrelation, list

Display within-cluster correlations for ID 258 . estat wcorrelation, at(id=258) list

--------------------------------------------------------------------------- Setup . webuse pig, clear . mixed weight i.week || id:, reml

Calculate and compare the DFs using three different methods . estat df, method(kroger anova repeated)

Post the kroger method to e() . estat df, method(kroger) post

Test that coefficient on 2.week equals coefficient on 3.week, and adjust for small sample using the Kenward-Roger method . test 2.week = 3.week, small

--------------------------------------------------------------------------- Setup . webuse pig, clear . mixed weight i.week || id:, reml dfmethod(kroger)

Test that coefficient on 2.week equals coefficient on 3.week, and adjust for small sample using the Kenward-Roger method . test 2.week = 3.week, small

Test that all coefficients on i.week are 0, and adjust for small sample using the Kenward-Roger method . testparm i.week, small

Estimate a linear combination of fixed effects, and adjust for small sample using the Kenward-Roger method . lincom 2.week + 3.week, small

--------------------------------------------------------------------------- Setup . webuse cont3way, clear . mixed y sex##race || group:, reml dfmethod(kroger)

Test the main effects of each factor with small-sample adjustment using the Kenward-Roger method . contrast sex race, small

Test the reference category contrasts of race, and adjust for small sample . contrast r.race, small

Test the interaction effects with small-sample adjustment . contrast race#sex, small

---------------------------------------------------------------------------

Stored results

pwcompare with option small stores the following in r():

Matrices r(L_df) degrees of freedom for each margin difference r(M_df) degrees of freedom for each margin estimate

pwcompare with options post and small stores the following in e():

Matrices e(L_df) degrees of freedom for each margin difference e(M_df) degrees of freedom for each margin estimate

Reference

Rabe-Hesketh, S., and A. Skrondal. 2012. Multilevel and Longitudinal Modeling Using Stata. 3rd ed. College Station, TX: Stata Press.


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index