Stata 15 help for glm_postestimation

[R] glm postestimation -- Postestimation tools for glm

Postestimation commands

The following postestimation commands are available after glm:

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) estat (svy) postestimation statistics for survey data estimates cataloging estimation results + forecast dynamic forecasts and simulations + hausman Hausman's specification test lincom point estimates, standard errors, testing, and inference for linear combinations of coefficients linktest link test for model specification *+ 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 suest seemingly unrelated estimation test Wald tests of simple and composite linear hypotheses testnl Wald tests of nonlinear hypotheses ------------------------------------------------------------------------- * estat ic and lrtest are not appropriate after glm, irls. + forecast, hausman, and lrtest are not appropriate with svy estimation results. forecast is also not appropriate with mi estimation results.

Syntax for predict

predict [type] newvar [if] [in] [, statistic options]

statistic Description ------------------------------------------------------------------------- Main mu expected value of y; the default xb linear prediction eta synonym of xb stdp standard error of the linear prediction anscombe Anscombe (1953) residuals cooksd Cook's distance deviance deviance residuals hat diagonals of the "hat" matrix likelihood a weighted average of standardized deviance and standardized Pearson residuals pearson Pearson residuals response differences between the observed and fitted outcomes score first derivative of the log likelihood with respect to xb working working residuals -------------------------------------------------------------------------

options Description ------------------------------------------------------------------------- Options nooffset modify calculations to ignore offset variable adjusted adjust deviance residual to speed up convergence standardized multiply residual by the factor (1-h)^[-1/2] studentized multiply residual by one over the square root of the estimated scale parameter modified modify denominator of residual to be a reasonable estimate of the variance of depvar ------------------------------------------------------------------------- These statistics are available both in and out of sample; type predict ... if e(sample) ... if wanted only for the estimation sample. mu, xb, stdp, and score are the only statistics allowed with svy estimation results.

Menu for predict

Statistics > Postestimation

Description for predict

predict creates a new variable containing predictions such as expected values, linear predictions, standard errors, residuals, Cook's distance, diagonals of the "hat" matrix, weighted averages, differences between the observed and fitted outcomes, and equation-level scores.

Options for predict

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

mu, the default, specifies that predict calculate the expected value of y, equal to the number of trials times the inverse link of the linear prediction.

xb calculates the linear prediction.

eta is a synonym for xb.

stdp calculates the standard error of the linear predictor.

anscombe calculates the Anscombe (1953) residuals to produce residuals that closely follow a normal distribution.

cooksd calculates Cook's distance, which measures the aggregate change in the estimated coefficients when each observation is left out of the estimation.

deviance calculates the deviance residuals. Deviance residuals are recommended by McCullagh and Nelder (1989) and by others as having the best properties for examining the goodness of fit of a GLM. They are approximately normally distributed if the model is correct. They may be plotted against the fitted values or against a covariate to inspect the model's fit. Also see the pearson option below.

hat calculates the diagonals of the "hat" matrix, analogous to linear regression.

likelihood calculates a weighted average of standardized deviance and standardized Pearson residuals.

pearson calculates the Pearson residuals. Pearson residuals often have markedly skewed distributions for nonnormal family distributions. Also see the deviance option above.

response calculates the differences between the observed and fitted outcomes.

score calculates the equation-level score, the derivative of the log likelihood with respect to the linear prediction.

working calculates the working residuals, which are response residuals weighted according to the derivative of the link function.

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

nooffset is relevant only if you specified offset(varname) for glm. It modifies the calculations made by predict so that they ignore the offset variable; the linear prediction is treated as xb rather than xb + offset.

adjusted adjusts the deviance residual to speed up the convergence to the limiting normal distribution. The adjustment deals with adding to the deviance residual a higher-order term that depends on the variance function family. This option is allowed only when deviance is specified.

standardized requests that the residual be multiplied by the factor (1-h)^[-1/2], where h is the diagonal of the hat matrix. This operation is done to account for the correlation between depvar and its predicted value.

studentized requests that the residual be multiplied by one over the square root of the estimated scale parameter.

modified requests that the denominator of the residual be modified to be a reasonable estimate of the variance of depvar. The base residual is multiplied by the factor (k/w)^[-1/2], where k is either one or the user-specified dispersion parameter and w is the specified weight (or one if left unspecified).

Syntax for margins

margins [marginlist] [, options]

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

statistic Description ------------------------------------------------------------------------- mu expected value of y; the default xb linear prediction eta synonym for xb stdp not allowed with margins anscombe not allowed with margins cooksd not allowed with margins deviance not allowed with margins hat not allowed with margins likelihood not allowed with margins pearson not allowed with margins response not allowed with margins score not allowed with margins working 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 expected values and linear predictions.

Examples

Setup . webuse ldose

Fit model to grouped binomial data . glm r ldose, family(binomial n) link(logit)

Calculate expected number of failures . predict mu_logit

Calculate deviance residuals . predict dr_logit, deviance

Perform link test . linktest, family(binomial n) link(logit)

References

Anscombe, F. J. 1953. Contribution of discussion paper by H. Hotelling "New light on the correlation coefficient and its transforms". Journal of the Royal Statistical Society, Series B 15: 229-230.

McCullagh, P., and J. A. Nelder. 1989. Generalized Linear Models. 2nd ed. London: Chapman & Hall/CRC.


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