------------------------------------------------------------------------------- help forcprplot2,cprplots2-------------------------------------------------------------------------------

Graph component-plus-residual plots for transformed regressors

cprplot2varlist[ifexp] [inrange] [,retransform(exp)yretransform(exp)rlopts(cline_options)lowesslsopts(lowess_options)msplinemsopts(mspline_options)lpolylpopts(lpoly_options)plot(plot)scatter_optionstwoway_options]

cprplots2vargroups[ifexp] [inrange] [,retransform(explist)yretransform(explist)rlopts(cline_options)lowesslsopts(lowess_options)msplinemsopts(mspline_options)lpolylpopts(lpoly_options)scatter_optionscombine_options]where

vargroupsis"

varlist" "varlist" ...and

explistis"

exp" "exp" ...

cprplot2andcprplots2are for use afterregressandanova; see help regress and anova.

Description

cprplot2is a variation of official Stata'scprplot(see help cprplot) and is used for graphing component-plus-residual plots (a.k.a. partial residual plots). There are three main additional features (compared tocprplot):(1) The partial residuals (and the "partial" predictions that are used to draw the reference line) can be computed taking into account multiple variables (the

varlist). These adjusted values are then plotted against thefirstvariable invarlist.cprplot2can therefore be used to produce a single component-plus-residual plot for a variable that enters the model repeatedly via different transformations (for example, polynomials). Note that all variables invarlistmust be independent variables currently included in the model.(2) Regressors entering the model via a univariate transformation can be re-transformed before drawing the plots using the

retransform()option. It is thus possible to display the plots using the original units of the regressors. Naturally, the reference line (i.e. the line representing the predictions from the model being estimated) will be curved in the re-transformed plot. Moreover, it is possible to re-transform the-right hand side of the equation, i.e. the partial residuals, using theyretransform()option. This may be useful for models with a transformed dependent variable.(3) The

cprplots2command offers the possibility of quickly displaying several component-plus-residual plots in a single image. Ifvargroupsis omitted, component-plus-residual plots are graphed for all independent variables in the model.cprplots2is implemented as a wrapper forcprplot2and supports features (1) and (2) discussed above.

cprplot2only uses observations that are in the estimation sample. Useifandinto further restrict the sample.

Options

retransform(exp)specifies that the regressor used in the graph be transformed through the application ofexp(see help exp). Use@as a placeholder for the regressor inexp. For example, assume that the regressor has been centered for the purpose of model estimation and that the sample mean of the regressor is 21.2973. To use the original scale of the regressor in the plot, specifyretransform(@+21.2973). Ifexpdoes not contain@,@is appended to the end ofexpin parentheses. Thus, say,retransform(exp)is equivalent toretransform(exp(@)).If you use

retransform()withcprplots2, specify either a singleexp(enclosed in double quotes if containing blanks) to be applied to all plots or a list ofexps to be applied one after another to the individual plots. Enclose individualexps that contain blanks with double quotes. Type""to indicate that no transformation be applied to a certain plot. Example:retransform("" "1/@" "").

yretransform(exp)specifies that the partial residuals (and the "partial" predictions which are used to draw the reference line) be transformed. See theretransform()option above.

rlopts(cline_options)affect the rendition of the reference curve; see help cline_options.

lowessadds a lowess smooth of the plotted points in order to assist in detecting nonlinearities.

lsopts(lowess_options)affect the rendition of the lowess smooth; see help twoway_lowess. Specifyinglsopts()implies thelowessoption.

msplineadds a median spline of the plotted points in order to assist in detecting nonlinearities.

msopts(mspline_options)affect the rendition of the median spline smooth; see help twoway_mspline. Specifyingmsopts()implies themsplineoption.

lpolyadds a local polynomial smooth of the plotted points in order to assist in detecting nonlinearities. Stata 10 is required.

lpopts(lpoly_options)affect the rendition of the local polynomial smooth; see help twoway_lpoly. Specifyinglpopts()implies thelpolyoption. Stata 10 is required.

plot(plot)provides a way to add other plots to the generated graph; see help plot_option.

scatter_optionsaffect the rendition of the plotted points; see help scatter.

twoway_optionsare any of the options documented in help twoway_options excludingby(). These include options for titling the graph (see help title_options) and options for saving the graph to disk (see help saving_option).

combine_optionsare any of the options documented in help graph_combine. These include options for titling the graph (see help title_options) and options for saving the graph to disk (see help saving_option).

Examples. sysuse auto . generate mpg2 = mpg^2 . generate mpg3 = mpg^3 . regress price weight mpg mpg2 mpg3 . cprplot2 mpg mpg2 mpg3 . cprplots2 weight "mpg mpg2 mpg3"

. generate lnmpg = ln(mpg) . regress price weight lnmpg . cprplot2 lnmpg, retransform(exp(@)) . cprplots2 weight lnmpg, retransform("" "exp(@)")

. gen lnweight = ln(weight) . reg lnweight mpg . cprplots2 mpg mpg , yretransform("" "exp(@)")

AuthorBen Jann, ETH Zurich, jann@soz.gess.ethz.ch

Also seeManual:

[R] regress,[R] regression diagnostics