msrrd — Risk Ratio and Risk Difference estimation using Marginal standardisation (G-computation) method

Computes Risk Ratio (RR) and Risk Difference (RD) using Marginal standardisation (G-computation) method (see margins).

Standard errors and 95% CI's are computed using the delta-method (see nlcom).

The command will also displays n/N (%) by group (and for each subgroup if subgroup option selected).

Syntax

msrrd varname
,
subgroup(subgroup_varname)
subtype(rr/rd/both)
rrdp(#)
rddpprop(#)
rddppct(#)
pdp(#)
pctdp(#)
vceuncond

Important notes/rules for command to run correctly

varname must be a binary variable coded 0/1 where 0=Comparator group and 1=Intervention group.

For command msrrd, varname should not to be specifed as factor variable operator (e.g. i.varname) and instead just inputted as varname.

However, varname must be specified as factor variable operator (e.g. i.varname) in the fitted model.

If subgroup option is selected, the fitted model must contain the interaction term i.varname#i.subgroup_varname or i.varname##i.subgroup_varname as factor variable operators.

For command msrrd, subgroup_varname should not to be specifed specifed as factor variable operator (e.g. i.subgroup_varname) and instead just inputted as subgroup_varname.

If vceuncond option is selected, this will calculate the SE's from margins allowing for sampling of covariates.

Note option vceuncond will only work if robust/cluster robust SE was specified in fitted model (see vcetype).

The command msrrd will only work if a [logistic] or [logit] or [melogit] or [glm / meglm with binomial family and logit link] is fitted first.

Options

Formatting

rrdp(#) Number of decimal places for RR and CI.
[Default is 4].

rddpprop(#) Number of decimal places for RD (proportion) and CI.
[Default is 4].

rddppct(#) Number of decimal places for RD (percentage) and CI.
[Default is 2].

pdp(#) Number of decimal places for all p-values.
[Default is 4].

pctdp(#) Number of decimal places for percentage in statistic n/N (%).
[Default is 1].

Subgroup analysis

subgroup(subgroup_varname)
Compute subgroup-specific RR/RD using marginal standardisation for each level of subgroup_varname.

subtype(rr/rd/both) rr — risk ratio only; rd — risk difference only; both — both RR and RD. [Default is both].

vce(unconditional)

vceuncond Specifies margins to use vce(unconditional) so that to estimate SEs allowing for sampling of covariates. [Default is vce(delta) if option vceuncond not included].

Description

The command performs the following steps:

1. Runs margins varname, post [or margins varname#subgroup_varname, post when subgroup option selected].

If option vceuncond included then vce(unconditional) is added as an option in margins so that SE's are computed allowing for sampling of covariates.

2. Extracts predicted risks and their variance–covariance matrix from r(b) and r(V).

3. Computes RR = p1 / p0 and its log–scale variance using the delta-method.

4. Computes RD = p1 – p0 and its variance using the delta-method.

5. Produces 95% confidence intervals, z–statistics, and p–values for both RR and RD.

RR is reported on the ratio scale. RD is reported on the proportion and percentage scale.

If subgroup() is specified:

An interaction test is performed using testparm i.varname#i.subgroup.

The fitted model must contain the interaction term i.varname#i.subgroup or i.varname##i.subgroup else command will output error message.

Subgroup-specific RR and RD are computed using the same delta-method formulas.

Output is displayed per subgroup level according to subtype().

Examples

Set-up dataset

. webuse nhanes2d, clear

Fit a logistic model and compute RR and RD (default dp):

. logit highbp height weight age i.female i.race, vce(robust)

. msrrd female, vceuncond

Specify RR to 3dp, RD proportion to 5dp, RD percentage to 3dp and P-values to 3dp::

. msrrd female, rrdp(3) rddpprop(5) rddppct(3) pdp(3) vceuncond

Subgroup analysis (RR and RD):

. logistic highbp height weight age i.female##i.race, vce(robust)

. msrrd female, subgroup(race) subtype(both) vceuncond

Stored results

msrrd stores the following in r() [Note: results of subgroups not stored]:

Risk ratio

r(rr) Risk ratio

r(rr_lb) Lower 95% CI

r(rr_ub) Upper 95% CI

r(rr_z) z-statistic

r(rr_p) p-value

Risk difference (proportion)

r(rd) Risk difference (proportion)

r(rd_lb) Lower 95% CI

r(rd_ub) Upper 95% CI

r(rd_z) z-statistic

r(rd_p) p-value

Author

Samir Mehta — Senior Medical Statistician

Birmingham Clinical Trials Unit (BCTU)

University of Birmingham

s.mehta.1@bham.ac.uk