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)
noci
level(#)
lineopts(line_options)
addplot(plot)
generate(newvar1 [newvar2 newvar3])
]

Description

adjustrcspline displays 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 the at() option is specified, to the
specified numbers. The restricted cubic spline needs to be created
using mkspline2.

adjustrcspline will automatically compute the appropriate expected
values (i.e. detect the appropriate link function) for the following commands:
regress, logit, logistic, betafit,
probit, poisson, cloglog, and glm (with the exception
of the negative binomial link function). For other commands users can specify
the appropriate link function using the link() option. With the link()
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 the
custominvlink() 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 non-factor variables at their mean and all
factor variables at the mode (if there is more then one mode,
the mode with the smallest value will be chosen). If the exposure()
option is specified in the estimation command, 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] glm and (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 with xb().

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

noci suppresses 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 in newvar1, newvar2 and
newvar3 respectively.

Examples

sysuse nlsw88, clear
recode grade 0/5=5

mkspline2 grades = grade, cubic nknots(3)
logit never_married grades*

adjustrcspline

(click to run)

sysuse uslifeexp, clear

mkspline2 ys = year, cubic
reg le ys* if year != 1918

adjustrcspline 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 flu")

(click to run)

sysuse nlsw88, clear
recode grade 0/5=5

mkspline2 grades = grade, cubic nknots(3)
logit never_married grades*

adjustrcspline, custominvlink("1/(1+exp(-1*xb()))")

(click to run)

sysuse nlsw88, clear
recode grade 0/5=5

mkspline2 grades = grade, cubic nknots(3)
glm never_married grades* south, link(cloglog) family(binomial)

adjustrcspline, at(south=0)

(click to run)

sysuse cancer, clear
gen long id = _n
stset 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)

References

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

Author

Maarten L. Buis

Wissenschaftszentrum Berlin für Sozialforschung (WZB)

Research unit Skill Formation and Labor Markets

maarten.buis@wzb.eu

Acknowledgement

Phil Clayton has given useful comments.

Suggested citation if using adjustrcspline in published work

adjustrcspline is 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