📄 predict.hlp
字号:
{smcl}
{* 22mar2005}{...}
{cmd:help predict}{right:dialog: {bf:{dialog predict}}}
{hline}
{title:Title}
{p2colset 5 20 22 2}{...}
{p2col :{hi:[R] predict} {hline 2}}Obtain predictions, residuals, etc., after
estimation{p_end}
{p2colreset}{...}
{title:Syntax}
{phang}
After single-equation (SE) models
{p 8 16 2}
{cmd:predict} {dtype} {newvar} {ifin} [{cmd:,}
{it:{help predict##single_options:single_options}}]
{phang}
After multiple-equation (ME) models
{p 8 16 2}
{cmd:predict} {dtype} {newvar} {ifin} [{cmd:,}
{it:{help predict##multiple_options:multiple_options}}]
{p 8 16 2}
{cmd:predict} {dtype} {c -(}{it:stub*}{c |}{it:newvar1} ... {it:newvarq}{c )-}
{ifin} {cmd:,} {opt sc:ores}
{synoptset 23 tabbed}{...}
{marker single_options}
{synopthdr :single_options}
{synoptline}
{syntab :Main}
{synopt :{opt xb}}calculate linear prediction{p_end}
{synopt :{opt stdp}}calculate standard error of the prediction{p_end}
{synopt :{opt sc:ore}}calculate first derivative of the log likelihood with
respect to xb{p_end}
{syntab :Options}
{synopt :{opt nooff:set}}ignore any {opt offset()} or {opt exposure()}
variable{p_end}
{synopt :{it:other_options}}command-specific options{p_end}
{synoptline}
{p2colreset}{...}
{synoptset 23 tabbed}{...}
{marker multiple_options}{...}
{synopthdr :multiple_options}
{synoptline}
{syntab :Main}
{synopt :{opt eq:uation}{cmd:(}{it:eqno}[{cmd:,}{it:eqno}]{cmd:)}}specify equations{p_end}
{synopt :{opt xb}}calculate linear prediction{p_end}
{synopt :{opt stdp}}calculate standard error of the prediction{p_end}
{synopt :{opt stddp}}calculate the difference in linear predictions{p_end}
{syntab :Options}
{synopt :{opt nooff:set}}ignore any {opt offset()} or {opt exposure()} variable{p_end}
{synopt :{it:other_options}}command-specific options{p_end}
{synoptline}
{p2colreset}{...}
{title:Description}
{pstd}
{cmd:predict} calculates predictions, residuals, influence statistics, and the
like after estimation. Exactly what {cmd:predict} can do is determined by the
previous estimation command; command-specific options are documented with each
estimation command. Regardless of command-specific options, the actions of
{cmd:predict} share certain similarities across estimation commands:
{phang2}1){space 2}{cmd:predict} {newvar} creates {it:newvar} containing
"predicted values"{hline 2}numbers related to the E(y|x). For instance,
after linear regression, {cmd:predict} {it:newvar} creates xb and, after
probit, creates the probability F(xb).
{phang2}2){space 2}{cmd:predict} {newvar}{cmd:,} {opt xb} creates {it:newvar}
containing xb. This may be the same result as (1) (e.g., linear
regression) or different (e.g., probit), but regardless, option {opt xb} is
allowed.
{phang2}3){space 2}{cmd:predict} {newvar}{cmd:,} {opt stdp} creates
{it:newvar} containing the standard error of the linear prediction xb.
{phang2}4){space 2}{cmd:predict} {it:newvar}{cmd:,} {it:other_options} may
create {it:newvar} containing other useful quantities; see help for the
particular estimation command to find out about other available options.
{phang2}5){space 2}{cmd:nooffset} added to any of the above commands
requests that the calculation ignore any offset or exposure variable
specified by including the {opt offset(varname)} or {opt exposure(varname)}
options when you fitted the model.
{pstd}
{cmd:predict} can be used to make in-sample or out-of-sample predictions:
{phang2}6){space 2}{cmd:predict} calculates the requested
statistic for all possible observations, whether they were used in fitting
the model or not. {cmd:predict} does this for the standard options (1)
through (3) and generally does this for estimator-specific options (4).
{phang2}7){space 2}{cmd:predict} {newvar} {cmd:if e(sample),} {it:...}
restricts the prediction to the estimation subsample.
{phang2}8){space 2}Some statistics make sense only with respect to the
estimation subsample. In such cases, the calculation is automatically
restricted to the estimation subsample, and the documentation for the specific
option states this. Even so, you can still specify {cmd:if e(sample)} if you
are uncertain.
{phang2}9){space 2}{cmd:predict} can make out-of-sample predictions even
using other datasets. In particular, you can
{pmore2}{cmd:. use ds1}{p_end}
{it:(fit a model)}
{pmore2}{cmd:. use two} {space 12} /* another dataset */{p_end}
{pmore2}{cmd:. predict yhat,} {it:...} {space 2} /* fill in the predictions */
{title:Options}
{dlgtab:Main}
{phang}
{opt xb} calculates the linear prediction from the fitted model.
{phang}
{opt stdp} calculates the standard error of the linear prediction.
{phang}
{opt stddp} is allowed only after you have previously fitted a
multiple-equation model. The standard error of the difference in linear
predictions between two equations is calculated. This option requires that
{opt equation(eqno1,eqno2)} be specified.
{phang}
{opt score} calculates the equation-level score; this is usually the
derivative of the log likelihood with respect to the linear prediction.
{phang}
{opt scores} is the ME model equivalent of the {opt score} option, resulting
in multiple equation-level score variables. An equation-level score variable
is created for each equation in the model; ancillary parameters{hline 2}such as
ln(sigma) and atanh(rho){hline 2}make up separate equations.
{phang}
{cmd:equation(}{it:eqno}[{cmd:,}{it:eqno}]{cmd:)}{hline 2}synonym
{opt outcome()}{hline 2}is relevant only when you have previously fitted a
multiple-equation model. It specifies the equation to which you are
referring.
{pmore}
{opt equation()} is typically filled in with one {it:eqno}{hline 2}it would
be filled in that way with options {opt xb} and {opt stdp}, for instance.
{cmd:equation(#1)} would mean the calculation is to be made for the first
equation, {cmd:equation(#2)} would mean the second, and so on. Alternatively,
you could refer to the equations by their names. {cmd:equation(income)} would
refer to the equation named income and {cmd:equation(hours)} to the equation
named hours.
{pmore}
If you do not specify {opt equation()}, results are the same as if you
specified {cmd:equation(#1)}.
{pmore}
Other statistics, such as {opt stddp}, refer to between-equation concepts.
In those cases, you might specify {cmd:equation(#1,#2)} or
{cmd:equation(income,hours)}. When two equations must be specified,
{opt equation()} is required.
{dlgtab:Options}
{phang}
{opt nooffset} may be combined with most statistics and specifies that
the calculation should be made, ignoring any offset or exposure variable
specified when the model was fitted.
{pmore}
This option is available, even if not documented for {opt predict} after a
specific command. If neither the {opt offset(varname)} option nor the
{opt exposure(varname)} option was specified when the model was fitted,
specifying {opt nooffset} does nothing.
{phang}
{it:other_options} refers to command-specific options that are documented with
each command.
{title:Examples}
{phang2}{cmd:. regress y x1 x2 x3}{p_end}
{phang2}{cmd:. predict yhat}{p_end}
{phang2}{cmd:. predict e if e(sample), resid}{p_end}
{phang2}{cmd:. predict c, cooksd}
{pstd}
Note that {cmd:cooksd} is a regression-specific option; see {helpb regress}.
{phang2}{cmd:. logistic low age lwt smoke ptl ht ui}{p_end}
{phang2}{cmd:. predict index, xb}{p_end}
{phang2}{cmd:. predict phat}
{pstd}
Note that {cmd:predict} without options calculates the predicted
probability in this case; see {helpb logistic}.
{phang2}{cmd:. mlogit y x1 x2 x3}{p_end}
{phang2}{cmd:. predict p1, eq(1)}{p_end}
{phang2}{cmd:. predict p2, eq(2)}{p_end}
{phang2}{cmd:. predict p3, eq(3)}
{pstd}
{cmd:predict} after {cmd:mlogit} also calculates probabilities by default;
see {helpb mlogit}.
{phang2}{cmd:. mvreg headroom trunk = price mpg foreign}{p_end}
{phang2}{cmd:. predict predhdr, eq(headroom)}{p_end}
{phang2}{cmd:. predict predtr, eq(trunk)}
{title:Also see}
{psee}
Manual: {bf:[R] predict}
{psee}
Online: {helpb _predict}, {helpb predictnl}, {helpb _pred_se},
{helpb regress},
{help regress postestimation}
{p_end}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -