📄 predictnl.hlp
字号:
{smcl}
{* 10mar2005}{...}
{cmd:help predictnl}{right:dialog: {bf:{dialog predictnl}}}
{hline}
{title:Title}
{p2colset 5 22 24 2}
{p2col :{hi:[R] predictnl} {hline 2}}Obtain nonlinear predictions, standard
errors, etc., after estimation{p_end}
{p2colreset}{...}
{title:Syntax}
{p 8 18 2}
{cmd:predictnl} {dtype} {newvar} = {it:pnl_exp} {ifin} [{cmd:,} {it:options}]
{synoptset 20 tabbed}{...}
{synopthdr}
{synoptline}
{syntab :Main}
{synopt :{opth se(newvar)}}create {it:newvar} containing standard errors{p_end}
{synopt :{opth var:iance(newvar)}}create {it:newvar} containing
variances{p_end}
{synopt :{opth w:ald(newvar)}}create {it:newvar} containing the Wald test
statistic{p_end}
{synopt :{opth p(newvar)}}create {it:newvar} containing the significance level
(p-value) of the Wald test{p_end}
{synopt :{opth ci:(newvarlist:newvars)}}create {it:newvars} containing lower and upper
confidence intervals{p_end}
{synopt :{opt l:evel(#)}}set confidence level; default is
{cmd:level(95)}{p_end}
{synopt :{opt g(stub)}}create {it:stub}{cmd:1}, {it:stub}{cmd:2}, ..., {it:stub}{cmd:k} variables containing observation-specific derivatives{p_end}
{syntab :Advanced}
{synopt :{opt i:terate(#)}}maximum iterations for finding optimal step size;
default is 100{p_end}
{synopt :{opt force}}calculate standard errors, etc., even when possibly
inappropriate{p_end}
{synoptline}
{p2colreset}{...}
{title:Description}
{pstd}
{cmd:predictnl} calculates (possibly) nonlinear predictions after any Stata
estimation command and optionally calculates the variances, standard errors,
Wald test statistics, significance levels, and confidence limits
for these predictions. Unlike its companion "nonlinear" postestimation
commands {helpb testnl} and {helpb nlcom}, {cmd:predictnl} generates functions
of the data (i.e., predictions), not scalars. The quantities generated by
{cmd:predictnl} are thus vectorized over the observations in the data.
{pstd}
The calculation of standard errors (and other obtainable quantities that are
based on the standard errors, such as test statistics) is based on the "delta
method", an approximation appropriate in large samples.
{pstd}
{cmd:predictnl} supports {helpb svy} estimation commands
({helpb "svy: regress"}, {helpb "svy: logit"}, etc.).
{pstd}
{it:pnl_exp} is any valid Stata expression and may also contain calls to two
special functions unique to {cmd:predictnl}:
{p 8 11 6}
1. {cmd:predict(}[{it:predict_options}]{cmd:)}:
When you are evaluating {it:pnl_exp}, the {cmd:predict()} is a convenience
function that replicates the calculation performed by the command
{cmd:predict ...,} {it:predict_options}
{p 11 11 6}
As such, {cmd:predict()} function may be used either as a shorthand for the
formula used to make this prediction or when the formula is not readily
available. When used without arguments, {cmd:predict()} replicates the
default prediction for that particular estimation command.
{p 8 11 6}
2. {cmd:xb(}[{it:eqno}]{cmd:)}: The {cmd:xb()} function replicates the
calculation of the linear predictor x_j*b for equation {it:eqno}.
If {cmd:xb()} is specified without {it:eqno}, the linear predictor for
the first equation (or the only equation in single-equation estimation) is
obtained.
{p 11 11 6}
For example, {cmd:xb(#1)} (or equivalently {cmd:xb()}) with no arguments)
translates to the linear predictor for the first equation, {cmd:xb(#2)} for the
second, and so on. Alternatively, you could refer to the equations by their
names, such as {cmd:xb(income)}.
{p 11 11 6}
When specifying {it:pnl_exp}, both of these functions may be used repeatedly,
in combination, and in combination with other Stata functions and expressions.
{title:Options}
{dlgtab:Main}
{phang}
{opth se(newvar)} adds {it:newvar} of storage type {it:type}, where for each
{opt i} in the prediction sample, {it:newvar}{cmd:[i]} contains the estimated
standard error of {it:pnl_exp}{cmd:[i]}.
{phang}
{opth variance(newvar)} adds {it:newvar} of storage type {it:type}, where
for each {opt i} in the prediction sample, {it:newvar}{cmd:[i]} contains the
estimated variance of {it:pnl_exp}{cmd:[i]}.
{phang}
{opth wald(newvar)} adds {it:newvar} of storage type {it:type}, where
for each {opt i} in the prediction sample, {it:newvar}{cmd:[i]} contains the
Wald test statistic for the test of the hypothesis H0:{it:pnl_exp}{cmd:[i]}=0.
{phang}
{opth p(newvar)} adds {it:newvar} of storage type {it:type}, where
{it:newvar}{cmd:[i]} contains the significance level (p-value) of the Wald
test H0:{it:pnl_exp}{cmd:[i]}=0 versus the two-sided alternative.
{phang}
{opth ci:(newvarlist:newvars)}
requires the specification of two {it:newvars}, such that
the {it:i}th observation of each will contain the left and right endpoints
(respectively) of a confidence interval for {it:pnl_exp}{cmd:[i]}. The level
of the confidence intervals is determined by {cmd:level(#)}.
{phang}
{cmd:level(#)} specifies the confidence level, as a percentage, for
confidence intervals. The default is {cmd:level(95)} or as set by
{helpb set level}.
{phang}
{opt g(stub)} specifies that new variables, {it:stub}{cmd:1},
{it:stub}{cmd:2}, ..., {it:stub}{cmd:k} be created, where {opt k} is the
dimension of e(b). {it:stub}{cmd:1} will contain the observation specific
derivatives of {it:pnl_exp} with respect to the first element listed in
e(b), of e(b) {it:stub}{cmd:2} will contain the derivatives of {it:pnl_exp}
with respect to the e(b), etc. If the derivative of {it:pnl_exp} with
respect to a particular coefficient in e(b) equals zero for all observations
in the prediction sample, the {it:stub} variable for that coefficient is not
created. Note that the ordering of the parameters in e(b) is precisely that
of the stored vector of parameter estimates e(b).
{dlgtab:Advanced}
{phang}
{opt iterate(#)} specifies the maximum number of iterations used to find the
optimal step size in the calculation of numerical derivatives of
{it:pnl_exp} with respect to estimated model coefficients. By default, the
maximum number of iterations is 100, but convergence is usually achieved only
after a few iterations. You should rarely have to use this option.
{phang}
{opt force} forces the calculation of standard errors and other
inference-related quantities in situations where {opt predictnl} would
otherwise refuse to do so. The calculation of standard errors takes place by
evaluating the numerical derivative of {it:pnl_exp} with respect to
to the coefficient vector e(b). If {opt predictnl} detects that {it:pnl_exp}
is possibly a function of random quantities other than e(b), it will refuse
to calculate standard errors or any other quantity derived from them. The
{opt force} option forces the calculation to take place, anyway. If you use
the {opt force} option, there is no guarantee that any inference quantities
(e.g., as standard errors) will be correct or that the values obtained can be
interpreted.
{title:Remark on the manipulability of nonlinear Wald tests}
{pstd}
In contrast to likelihood ratio tests, different{hline 2}mathematically
equivalent{hline 2}formulations of an hypothesis may lead to different results
for a nonlinear Wald test (lack of "invariance"). For instance, the two
hypotheses
H0: {it:pnl_exp}{cmd:[i]} = 0
H0: exp({it:pnl_exp}{cmd:[i]}) - 1 = 0
{pstd}
are mathematically equivalent expressions, but do not yield the same test
statistic and p-value. In extreme cases, under one formulation, one would
reject H0 while under an equivalent formulation one would not reject Ho.
{title:Remark on the use of the functions {cmd:predict()} and {cmd:xb()}}
{pstd}
Note that when calculating inference-related quantities such as standard
errors, {it:pnl_exp} is evaluated repeatedly for different values of the model
parameters. As such, think of {cmd:predict()} and {cmd:xb()} as a means of
substituting for the {it:formula} of the calculation, and not a means of
substituting the value of the calculation that is obtained when the model
parameters are set to any specific values. For example,
{cmd:. predict double }{it:pred_var, predict_options}
{cmd:. predictnl }{it:newvar}{cmd: = }{it:pred_var}{cmd:, se(}{it:newvar_se}{cmd:)}
{pstd}
will give standard errors ({it:newvar_se}) equal to zero, since once
evaluated, {it:pred_var} will contain values that are fixed with respect to
e(b). Instead,
{phang2}{cmd:. predictnl }{it:newvar}{cmd: = predict(}{it:predict_options}{cmd:), se(}{it:newvar_se}{cmd:)}
{pstd}
will produce what is intended.
{title:Examples}
{phang}{cmd:. regress y x1 x2 x3 x4 z1 z2}{p_end}
{phang}{cmd:. predictnl p = _b[x1]*x1/(_b[x2]*x2) - 1, wald(pw) ci(pc1 pc2)}{p_end}
{phang}{cmd:. predictnl exb = exp(xb()), se(exb_se)}
{phang}{cmd:. mlogit insure age male nonwhite site2 site3}{p_end}
{phang}{cmd:. predictnl phat = predict(outcome(Indem))/predict(outcome(Prepaid))-1, p(sig_lev)}{p_end}
{phang}{cmd:. predictnl exb_2 = exp(xb(#2)), se(exb_se)}
{phang}{cmd:. streg drug age, dist(weibull)}{p_end}
{phang}{cmd:. predictnl t_hat = predict(mean time), se(t_hat_se)}
{title:Also see}
{psee}
Manual: {bf:[R] predictnl}
{psee}Online: {helpb lincom}, {helpb lrtest}, {helpb nlcom}, {helpb predict},
{helpb test}, {helpb testnl}
{p_end}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -