help for

adjustrcspline-------------------------------------------------------------------------------

Title

adjustrcspline-- Displays the adjusted predictions after using a restricted cubic spline.

Syntax

adjustrcspline[if] [in],[at(var=#[var=#[...]])link(linkname)custominvlink(inv_link_specification)ciopts(rarea_options)nocilevel(#)lineopts(line_options)addplot(plot)generate(newvar1[newvar2 newvar3])]

Description

adjustrcsplinedisplays a graph of adjusted predictions, after estimating a model that uses a restricted cubic spline as an explanatory variable. All other variables are set to their mean value or, if theat()option is specified, to the specified numbers. The restricted cubic spline needs to be created usingmkspline2.

adjustrcsplinewill automatically compute the appropriate expected values (i.e. detect the appropriate link function) for the following commands:regress,logit,logistic,betafit,probit,poisson,cloglog, andglm(with the exception of the negative binomial link function). For other commands users can specify the appropriate link function using thelink()option. With thelink()option you can specify the dentity, logit, probit, log, log-complement, log-log, complementary log-log, reciprocal, power, and the odds power links. If your model uses another link function you can specify that inverse link function (the transformation that needs to be applied to the linear predictor in order to get a prediction in the metric of the dependent variable ) with thecustominvlink()option.

Options

at(var=#[var=#[...]])specifies the values of the other explanatory variables (and offset or exposure) at which the predicted values are calculated. The default is to set all variables at their mean.The only exception is the default when the

exposure()option is specified in the estimation command. In that case the default is to set the exposure equal to the exp(mean(offset)).

link(linkname)specifies the link function used for computing the predictions. The link functions that can be specified are: identity, logit, probit, log, logcomplement, loglog, cloglog, reciprocal, power #, opower #. These link functions are described in[R] glmand (Hardin and Hilbe 2001).

custominvlink(inv_link_specification)specifies a user specified inverse link funtion, i.e. the transformation of the linear predictor that leads to the metric of the dependent variable. The syntax is the same as in predictnl, in particular the linear predictor can be specified withxb().

ciopts(rarea_options)specifies options of twoway rarea to tune the display of the confidence interval.

nocisuppresses the display of the confidence interval.

level(#)specifies a confidence level to use for confidence intervals. See help on level.

lineopts(line_options)specifies options of twoway line to tune the display of the point estimates of the adjusted predictions. These options can also be added directly, which can be convenient to change for instance the legend, axis titles, etc.

addplot(plot)provides a way to add other plots to the generated graph. See help on addplot_option.

generate(newvar1[newvar2 newvar3])specifies that the values of the adjusted predictions and optionally the lower and upper bounds of the confidence interval be saved innewvar1,newvar2andnewvar3respectively.

Examples

sysuse nlsw88, clearrecode grade 0/5=5mkspline2 grades = grade, cubic nknots(3)logit never_married grades*adjustrcspline(click to run)

sysuse uslifeexp, clearmkspline2 ys = year, cubicreg le ys* if year != 1918adjustrcspline if year != 1918, ///addplot(scatter le year if year != 1918, msymbol(Oh) || ///scatter le year if year == 1918, msymbol(X) ) ///ytitle("life expectancy") ///note("1918 was excluded from the computations because of the Spanish fl> u")(click to run)

sysuse nlsw88, clearrecode grade 0/5=5mkspline2 grades = grade, cubic nknots(3)logit never_married grades*adjustrcspline, custominvlink("1/(1+exp(-1*xb()))")(click to run)

sysuse nlsw88, clearrecode grade 0/5=5mkspline2 grades = grade, cubic nknots(3)glm never_married grades* south, link(cloglog) family(binomial)adjustrcspline, at(south=0)(click to run)

sysuse cancer, cleargen long id = _nstset studytime, failure(died) id(id)stsplit t, every(1)

mkspline2 ts=t, cubic nknots(3)xi: streg i.drug age ts*, dist(exp)adjustrcspline , at(_Idrug_2=0 _Idrug_3=0) ///link("log") ///noci ///ytitle(hazard)(click to run)

James W. Hardin and Joseph M. Hilbe (2001)ReferencesGeneralized Linear Models andExtensions, 2nd edition. College Station, TX: Stata Press.

AuthorMaarten L. Buis Universitaet Tuebingen Institut fuer Soziologie maarten.buis@ifsoz.uni-tuebingen.de

Suggested citation if using adjustrcspline in published work

adjustrcsplineis not an official Stata command. It is a free contribution to the research community, like a paper. Please cite it as such.Buis, Maarten L. 2009. "POSTRCSPLINE: Stata module containing post-estimation commands for models using a restricted cubic spline" http://ideas.repec.org/c/boc/bocode/s456928.html

Also see

If installed:

mfxrcspline,mkspline2,rcspline