help for xpredictPatrick Royston -------------------------------------------------------------------------------

Extension to predict

Syntax

xpredictnewvarname[if] [in],with(varlist)[options]

optionsDescription -------------------------------------------------------------------------a(numlist)defines constants for use in contrastsat(vn #[vn #...])predict at values of specified covariatesconstantincludes the regression constant in predictionsdoublemakesnewvarnamedouble precisioneq(eqname)defines the equation forvarlistmeanzerocentres the prediction on its meanstdppredicts the standard error of (partial) xb -------------------------------------------------------------------------

Description

xpredictgives predictions of the (partial) `index' xb from variables in the most recently fitted regression model.Note that none of the options of

predictavailable with specific regression commands are available withxpredict. Only prediction of xb and its SE are supported. Multi-equation models are supported via theeq()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. afterregressoranova.

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

constantincludes the regression constant (_cons) in the prediction. It is counted as the last predictor inwith().

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

eq(eqname)defines the name of the equation for varlist inwith(varlist). Only wheneqnameis the name of a subsidiary equation (i.e. not the 'main' equation or linear predictor) does it need to be specified at all. By defaultxpredictworks out the name of the main equation itself, by inspectinge(b).

meanzerocentres the predicted values on their mean. If thestdpoption is used, the standard error is adjusted accordingly. Note that with themeanzerooption,xpredictsubtracts the mean xb computed in the subsample defined by the [if] [in] filter, if any. The prediction of xb and its standard error (stdpoption) are done out of sample. Cases with any missing values for any member ofwith()are excluded.

stdppredicts 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_optionsare any of the options ofpredict(in general, these will be estimation-command specific, though some are always available; seepredict).

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)

AuthorPatrick Royston, MRC Clinical Trials Unit, London. pr@ctu.mrc.ac.uk

Also see