*! version 1.0.9 23apr2012
help for xpredictPatrick Royston

Extension to predict

Syntax

xpredict
newvarname
[if] [in]
,
with(varlist)
[options]

a(numlist) defines constants for use in contrasts

at(vn # [vn # ...]) predict at values of specified covariates

constant includes the regression constant in predictions

double makes newvarname double precision

eq(eqname) defines the equation for varlist

meanzero centres the prediction on its mean

stdp predicts the standard error of (partial) xb

Description

xpredict gives predictions of the (partial) `index' xb from variables
in the most recently fitted regression model.

Note that none of the options of predict available with specific regression
commands are available with xpredict. Only prediction of xb and its SE are
supported. Multi-equation models are supported via the eq() option.

Options

a(numlist) defines a set of constants by which the regression coefficients
for members of varlist are multiplied before prediction. This can be used
to estimate contrasts e.g. after regress or anova.

at(varname # [ varname # ...]) requests that the covariates specified by
the listed varname(s) be set to the listed # values. For example,
at(x1 1 x3 50) would evaluate predictions at x1 = 1 and
x3 = 50. This is a useful way to obtain out of sample predictions.

constant includes the regression constant (_cons) in the prediction. It is
counted as the last predictor in with().

double specifies that newvarname be of type double (double precision).
The default type is float.

eq(eqname) defines the name of the equation for varlist in with(varlist).
Only when eqname is the name of a subsidiary equation (i.e. not the 'main'
equation or linear predictor) does it need to be specified at all. By default
xpredict works out the name of the main equation itself, by inspecting
e(b).

meanzero centres the predicted values on their mean. If the stdp
option is used, the standard error is adjusted accordingly. Note that with
the meanzero option, xpredict subtracts the mean
xb computed in the subsample defined by the [if] [in] filter, if any.
The prediction of xb and its standard error (stdp option) are
done out of sample. Cases with any missing values for any member of
with() are excluded.

stdp predicts the standard error of (partial) xb.

with(varlist) is not optional and specifies the variables to be used.
These must be among the variables fitted in the most recent model.
Factor variables are allowed.

predict_options are any of the options of predict (in general, these will
be estimation-command specific, though some are always available; see
predict).

Examples

. regress y x1 x2 x3

. xpredict f, with(x1 x2) double

. xpredict fs, with(x1 x2) stdp

. xpredict f, with(x1 x2) constant

. xpredict f2, with(x1 x2) meanzero

. xpredict f2s, with(x1 x2) meanzero stdp

. poisson y x1 x2, exposure(pyears)

. xpredict f, with(x1) eq(y)

. stcox rem##sex i.who

. xpredict xb, with(1.sex 1.rem 1.sex#1.rem)

. table rem sex, contents(mean xb) format(%6.3)

Author

Patrick Royston, MRC Clinical Trials Unit, London.

pr@ctu.mrc.ac.uk

Also see

On-line: help for predict.