*! version 1.0 23 Aug 2020

Title

rcspc - Restricted cubic spline contrasts - Prefix command estimating effect
measure values (contrasts) from a reference value and their confidence
interval for a set of effect modifier values.

Syntax

rcspc, mandatory_options
[optional_options twoway_options]: regression command

Mandatory

at(numlist min=1 sort) A numlist of length greater than 1.
The values of the continuous effect at which to estimate the effect measure.

reference(numlist max=1) The reference value to contrast from.

Optional
pctknots(numlist min=3 max=10 >0 <100 sort) A numlist of
values between 0 and 100.
The length of the numlist must be between 3 and 10.
They specify the percentages of the percentiles that are used for calculating
the restricted cubic splines.

nknots(#) Integer value between 3 and 7 specifying recommended
standard set of percentages, described in [opt nknots} in
mkspline, Methods and formulas.
Default value is 4. If option pctknots is set, option nknots is
ignored.

keepcubicsplines Keep the generated cubic spline regressors for
detailed analysis.

includereference Include reference value in points and graph.
To when the reference value is outside the interval of the continuous effect
variable.

eform Exponentiate the estimated effect measures.

rcspcnames(namelist min=4 max=4) Rename the generated variables
with the requested values of the continuous effect variable,
the estimated effect measures
and the 95% CI for the estimated effect measure. Must have length 4.
Default names are "__second_variable_name", "__second_variable_name_contrast",
"__second_variable_name_lb" and "__second_variable_name_ub"

cilimits(numlist max=1 >50 <100) A numlist of length 1.
A real between 0 and 100.
Option to change the percentage for the confidence intervals from the
default 95 (%).

graph Generate a default graph.

twoway_options Generate a default graph with the twoway options.
Option graph is not necessary in this case.

Description

The prefix command rcspc takes a regression command as an argument.
From the regression command argument rcspc uses the first variable as an
outcome variable, the second as continuous effect variable transformed into a
function using cubic splines.

For each value in the numlist specified in the at option, the estimated
contrast from the specified reference value and the confidence interval
limits (normal approximation) are saved in four variables.
For reproducibility, detailed results are stored in the returned values.

A simple default graph of the estimates and the 95% confidence interval
are generated by the option graph.
It is deliberately simple but easily modifiable by any twoway option.
if any twoway option is set the the option graph is not necessary.

The calculations in prefix command rcspc are based on returned matrices e(b)
and e(V) and are therefore independent of the type of regression performed.
Interesting contrasts (directly or exponentiated) that may be studied with this
approach include:

* difference in means using -regress- or -mixed-

* odds ratios using -logit- or -logistic-

* odds ratios in a matched study using -clogit-

* risk differences using -binreg-

* relative risks using -binreg-

* hazard ratios using -stcox-

* incidence rate ratios using -poisson- or -nbreg-

Contrasts in -glm- are also possible to analyse.

The author developed this command to estimate and visualise effect modification
on a contrast or the log of the contrast.
However, the command can also be used to visualise gap developments by a
continuous variable e.g. visualising the income gap over time between the
two genders.

Examples

Data are described in Statistical Modeling for Biomedical Researchers.

The book is a very good reference.

Click once on the commands (blue text) below to perform these in Stata.

Retrieve data

. //biostat.mc.vanderbilt.edu/dupontwd/wddtext/data/1.4.11.Sepsis.dta", clear"'

Use the rcspc prefix command to estimate the risk differences for
apache scores 0(5)40 from reference value 0 and generate the default graph
named contrast

. `"rcspc, at(0(2)40) reference(0) name(contrast, replace) ytitle("Mortality risk difference, reference 0"): binreg fate apache, rd"'

Stored results

rcspc stores the following in r():

Macros

r(graph_cmd) The twoway graph command generating the graph.

r(rcspcnames) The names of the variables generated.

r(command) The regression command generating the estimates.

Matrices

r(predictions) Predicted unexposed, predicted exposed and
predicted contrast as well as their confidence intervals.

r(regressors) Regressors used for the predictions.

r(knots) The knots used for the unexposed and exposed parts
of the second risk factor.

Authors and support

Author:

Niels Henrik Bruun,

Aalborg University Hospital

Support:

niels.henrik.bruun@gmail.com