Stata 11 help for logistic postestimation

help logistic postestimation dialogs: predict estat lroc lsens also see: logistic -------------------------------------------------------------------------------

Title

[R] logistic postestimation -- Postestimation tools for logistic

Description

The following postestimation commands are of special interest after logistic:

command description ------------------------------------------------------------------------- estat classification reports various summary statistics, including the classification table estat gof Pearson or Hosmer-Lemeshow goodness-of-fit test lroc graphs the ROC curve and calculates the area under the curve lsens graphs sensitivity and specificity versus probability cutoff ------------------------------------------------------------------------- These commands are not appropriate after the svy prefix.

The following standard postestimation commands are also available:

command description ------------------------------------------------------------------------- estat AIC, BIC, VCE, and estimation sample summary estat (svy) postestimation statistics for survey data estimates cataloging estimation results lincom point estimates, standard errors, testing, and inference for linear combinations of coefficients linktest link test for model specification (1) lrtest likelihood-ratio test margins marginal means, predictive margins, marginal effects, and average marginal effects 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 suest seemingly unrelated estimation test Wald tests of simple and composite linear hypotheses testnl Wald tests of nonlinear hypotheses ------------------------------------------------------------------------- (1) lrtest is not appropriate with svy estimation results.

Special-interest postestimation commands

estat classification reports various summary statistics, including the classification table.

estat gof reports the Pearson goodness-of-fit test or the Hosmer-Lemeshow goodness-of-fit test.

lroc graphs the ROC curve and calculates the area under the curve.

lsens graphs sensitivity and specificity versus probability cutoff and optionally creates new variables containing these data.

estat classification, estat gof, lroc, and lsens produce statistics and graphs either for the estimation sample or for any set of observations. However, they always use the estimation sample by default. When weights, if, or in is used with logistic, it is not necessary to repeat the qualifier with these commands when you want statistics computed for the estimation sample. Specify if, in, or the all option only when you want statistics computed for a set of observations other than the estimation sample. Specify weights (only fweights are allowed with these commands) only when you want to use a different set of weights.

By default, estat classification, estat gof, lroc, and lsens use the last model fit by logistic. You may also directly specify the model to the lroc and lsens commands by inputting a vector of coefficients with the beta() option and passing the name of the dependent variable depvar.

estat classification and estat gof require that the current estimation results be from logistic, logit, or probit. lroc and lsens commands may also be used after logit or probit.

Syntax for predict

predict [type] newvar [if] [in] [, statistic nooffset rules asif]

statistic description ------------------------------------------------------------------------- Main pr probability of a positive outcome; the default xb linear prediction stdp standard error of the prediction * dbeta Pregibon Delta-Beta influence statistic * deviance deviance residual * dx2 Hosmer and Lemeshow Delta chi-squared influence statistic * ddeviance Hosmer and Lemeshow Delta-D influence statistic * hat Pregibon leverage * number sequential number of the covariate pattern * residuals Pearson residuals; adjusted for number sharing covariate pattern * rstandard standardized Pearson residuals; adjusted for number sharing covariate pattern score first derivative of the log likelihood with respect to x-Beta ------------------------------------------------------------------------- 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. pr, xb, stdp, and score are the only options allowed with svy estimation results.

Menu

Statistics > Postestimation > Predictions, residuals, etc.

Options for predict

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

pr, the default, calculates the probability of a positive outcome.

xb calculates the linear prediction.

stdp calculates the standard error of the linear prediction.

dbeta calculates the Pregibon Delta-Beta influence statistic, a standardized measure of the difference in the coefficient vector that is due to deletion of the observation along with all others that share the same covariate pattern. In Hosmer and Lemeshow jargon, this statistic is M-asymptotic; that is, it is adjusted for the number of observations that share the same covariate pattern.

deviance calculates the deviance residual.

dx2 calculates the Hosmer and Lemeshow Delta chi-squared influence statistic, reflecting the decrease in the Pearson chi-squared because of deletion of the observation and all others that share the same covariate pattern.

ddeviance calculates the Hosmer and Lemeshow Delta-D influence statistic, which is the change in the deviance residual that is due to deletion of the observation and all others that share the same covariate pattern.

hat calculates the Pregibon leverage or the diagonal elements of the hat matrix adjusted for the number of observations that share the same covariate pattern.

number numbers the covariate patterns -- observations with the same covariate pattern have the same number. Observations not used in estimation have number set to missing. The first covariate pattern is numbered 1, the second 2, and so on.

residuals calculates the Pearson residual as given by Hosmer and Lemeshow and adjusted for the number of observations that share the same covariate pattern.

rstandard calculates the standardized Pearson residual as given by Hosmer and Lemeshow and adjusted for the number of observations that share the same covariate pattern.

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

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

nooffset is relevant only if you specified offset(varname) for logistic. 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.

rules requests that Stata use any rules that were used to identify the model when making the prediction. By default, Stata calculates missing for excluded observations. See [R] logit for an example.

asif requests that Stata ignore the rules and the exclusion criteria and calculate predictions for all observations possible by using the estimated parameter from the model. See [R] logit for an example.

Syntax for estat classification

estat classification [if] [in] [weight] [, class_options]

class_options description ------------------------------------------------------------------------- Main all display summary statistics for all observations in the data cutoff(#) positive outcome threshold; default is cutoff(0.5) ------------------------------------------------------------------------- fweights are allowed; see weight.

Menu

Statistics > Postestimation > Reports and statistics

Options for estat classification

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

all requests that the statistic be computed for all observations in the data, ignoring any if or in restrictions specified by logistic.

cutoff(#) specifies the value for determining whether an observation has a predicted positive outcome. An observation is classified as positive if its predicted probability is > #. The default is 0.5.

Syntax for estat gof

estat gof [if] [in] [weight] [, gof_options]

gof_options description ------------------------------------------------------------------------- Main group(#) perform Hosmer-Lemeshow goodness-of-fit test using # quantiles all execute test for all observations in the data outsample adjust degrees of freedom for samples outside estimation sample table display table of groups used for test ------------------------------------------------------------------------- fweights are allowed; see weight.

Menu

Statistics > Postestimation > Reports and statistics

Options for estat gof

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

group(#) specifies the number of quantiles to be used to group the data for the Hosmer-Lemeshow goodness-of-fit test. group(10) is typically specified. If this option is not given, the Pearson goodness-of-fit test is computed using the covariate patterns in the data as groups.

all requests that the statistic be computed for all observations in the data, ignoring any if or in restrictions specified with logistic.

outsample adjusts the degrees of freedom for the Pearson and Hosmer-Lemeshow goodness-of-fit tests for samples outside the estimation sample.

table displays a table of the groups used for the Hosmer-Lemeshow or Pearson goodness-of-fit test with predicted probabilities, observed and expected counts for both outcomes, and totals for each group.

Syntax for lroc

lroc [depvar] [if] [in] [weight] [, lroc_options]

lroc_options description ------------------------------------------------------------------------- Main all compute area under ROC curve and graph curve for all observations nograph suppress graph

Advanced beta(matname) row vector containing coefficients for a logistic model

Plot cline_options change the look of the line marker_options change look of markers (color, size, etc.) marker_label_options add marker labels; change look or position

Reference line rlopts(cline_options) affect rendition of the reference line

Add plots addplot(plot) add other plots to the generated graph

Y axis, X axis, Titles, Legend, Overall twoway_options any options other than by() documented in [G] twoway_options ------------------------------------------------------------------------- fweights are allowed; see weight.

Menu

Statistics > Binary outcomes > Postestimation > ROC curve after logistic/logit/probit/ivprobit

Options for lroc

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

all requests that the statistic be computed for all observations in the data, ignoring any if or in restrictions specified by logistic.

nograph suppresses graphical output.

+----------+ ----+ Advanced +---------------------------------------------------------

beta(matname) specifies a row vector containing coefficients for a logistic model. The columns of the row vector must be labeled with the corresponding names of the independent variables in the data. The dependent variable depvar must be specified immediately after the command name.

+------+ ----+ Plot +-------------------------------------------------------------

cline_options, marker_options, and marker_label_options affect the rendition of the ROC curve -- the plotted points connected by lines. These options affect the size and color of markers, whether and how the markers are labeled, and whether and how the points are connected; see [G] cline_options, [G] marker_options, and [G] marker_label_options.

+----------------+ ----+ Reference line +---------------------------------------------------

rlopts(cline_options) affects the rendition of the reference line; see [G] cline_options.

+-----------+ ----+ Add plots +--------------------------------------------------------

addplot(plot) provides a way to add other plots to the generated graph; see [G] addplot_option.

+-----------------------------------------+ ----+ Y axis, X axis, Titles, Legend, Overall +--------------------------

twoway_options are any of the options documented in [G] twoway_options, excluding by(). These include options for titling the graph (see [G] title_options) and for saving the graph to disk (see [G] saving_option).

Syntax for lsens

lsens [depvar] [if] [in] [weight] [, lsens_options]

lsens_options description ------------------------------------------------------------------------- Main all graph all observations in the data genprob(varname) create variable containing probability cutoff gensens(varname) create variable containing sensitivity genspec(varname) create variable containing specificity replace overwrite existing variables nograph suppress the graph

Advanced beta(matname) row vector containing coefficients for the model

Plot connect_options affect rendition of the plotted points connected by lines

Add plots addplot(plot) add other plots to the generated graph

Y axis, X axis, Titles, Legend, Overall twoway_options any options other than by() documented in [G] twoway_options ------------------------------------------------------------------------- fweights are allowed; see weight.

Menu

Statistics > Binary outcomes > Postestimation > Sensitivity/specificity plot

Options for lsens

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

all requests that the statistic be computed for all observations in the data, ignoring any if or in restrictions specified with logistic.

genprob(varname), gensens(varname), and genspec(varname) specify the names of new variables created to contain, respectively, the probability cutoffs and the corresponding sensitivity and specificity.

replace requests that existing variables specified for genprob(), gensens(), or genspec() be overwritten.

nograph suppresses graphical output.

+----------+ ----+ Advanced +---------------------------------------------------------

beta(matname) specifies a row vector containing coefficients for a logistic model. The columns of the row vector must be labeled with the corresponding names of the independent variables in the data. The dependent variable depvar must be specified immediately after the command name.

+------+ ----+ Plot +-------------------------------------------------------------

connect_options affect the rendition of the plotted points connected by lines; see connect_options in [G] graph twoway scatter.

+-----------+ ----+ Add plots +--------------------------------------------------------

addplot(plot) provides a way to add other plots to the generated graph. See [G] addplot_option.

+-----------------------------------------+ ----+ Y axis, X axis, Titles, Legend, Overall +--------------------------

twoway_options are any of the options documented in [G] twoway_options, excluding by(). These include options for titling the graph (see [G] title_options) and for saving the graph to disk (see [G] saving_option).

Examples

. webuse lbw . logistic low age lwt i.race smoke ptl ht ui . lroc . lsens . estat class . estat gof . predict phat if e(sample) . predict r, resid

Saved results

estat classification saves the following in r():

Scalars r(P_corr) percent correctly classified r(P_p1) sensitivity r(P_n0) specificity r(P_p0) false-positive rate given true negative r(P_n1) false-negative rate given true positive r(P_1p) positive predictive value r(P_0n) negative predictive value r(P_0p) false-positive rate given classified positive r(P_1n) false-negative rate given classified negative

estat gof saves the following in r():

Scalars r(N) number of observations r(m) number of covariate patterns or groups r(df) degrees of freedom r(chi2) chi-squared

lroc saves the following in r():

Scalars r(N) number of observations r(area) area under the ROC curve

lsens saves the following in r():

Scalars r(N) number of observations

Also see

Manual: [R] logistic postestimation

Help: [R] logistic


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