*! version 1.0 13 Nov 2017

Title

emc - Effect modifier on contrasts - Prefix command estimating effect
measure values (contrasts) and their confidence interval for a set of
effect modifier values.

Syntax

emc, mandatory_options
[optional_options twoway_options]: regression command

Mandatory
at(numlist) A numlist of length greater than 1. The values of
the effect modifier at which to estimate the effect measure. Mandatory.

Optional
pctknots(numlist) 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.

eform Exponentiate the estimated effect measures.

emcnames(namelist) Rename the generated variables
with the requested values of the effect modifier, the estimated effect measures
and the 95% CI for the estimated effect measure. Must have length 4.
Default names are "__third_variable_name", "__third_variable_name_contrast",
"__third_variable_name_lb" and "__third_variable_name_ub"

cilimits(numlist) 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 emc takes a regression command as an argument.
From the regression command argument emc uses the first variable as an
outcome variable, the second as a dichotomous contrast variable and the third
as effect modifier transformed into a function using cubic splines.

For each value in the numlist specified in the at option, the estimated
contrast 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 emc 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 emc prefix command to estimate the risk at apache scores
from 0(5)40 and generate the default graph named contrast

. `"emc, at(0(5)40) name(contrast, replace): binreg fate treat apache, rd"'

The knots for unexposed(E0) and exposed(E1) are quite similar

. `"matlist r(knots)"'

Stored results

emc stores the following in r():

Macros

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

r(emnames) 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.

References

Presentation at 2019 Nordic and Baltic Stata Users Group meeting

Bruun (2019), Visualizing effect modification on contrasts. Stata Journal.

Authors and support

Author:

Niels Henrik Bruun,

Aalborg University Hospital

Support:

niels.henrik.bruun@gmail.com