Package 'interactionR'

Title: Full Reporting of Interaction Analyses
Description: Produces a publication-ready table that includes all effect estimates necessary for full reporting effect modification and interaction analysis as recommended by Knol and Vanderweele (2012) [<doi:10.1093/ije/dyr218>]. It also estimates confidence interval for the trio of additive interaction measures using the delta method (see Hosmer and Lemeshow (1992), [<doi:10.1097/00001648-199209000-00012>]), variance recovery method (see Zou (2008), [<doi:10.1093/aje/kwn104>]), or percentile bootstrapping (see Assmann et al. (1996), [<doi:10.1097/00001648-199605000-00012>]).
Authors: Babatunde Alli
Maintainer: Babatunde Alli <[email protected]>
License: GPL-3
Version: 0.1.7
Built: 2025-02-25 03:46:05 UTC
Source: https://github.com/tunsmart/interactionr

Help Index


Case-control data of the effect of sports participation and smoking on herniated lumbar disc examined by Assmann et al.

Description

A dataset containing three dichotomous variables: herniated lumbar disc, sports participation, and smoking

Usage

HDiscdata

Format

A data frame with 458 observations and 3 variables:

h

presence of herniated lumbar disc, the outcome

ns

presence or lack of sports participation, the first exposure

smk

smoking, the second exposure

...

Source

doi:10.1097/00001648-199605000-00012


Full reporting of effect modification and interaction analysis

Description

For two binary exposures included in a regression model as an interaction term for a binary outcome, interactionR returns all effect estimates necessary to fully report effect modification or interaction analysis as recommended by Knol and Vanderweele (2012) [doi:10.1093/ije/dyr218]. Estimation of confidence intervals (CI) for measures of additive interaction (RERI, AP, and SI) is based on the delta method described by Hosmer and Lemeshow (1992) [doi:10.1097/00001648-199209000-00012] or the variance recovery 'mover' method described by Zou (2008) [doi:10.1093/aje/kwn104].

Usage

interactionR(
  model,
  exposure_names = c(),
  ci.type = "delta",
  ci.level = 0.95,
  em = T,
  recode = F
)

Arguments

model

A fitted model object of class glm, clogit or coxph

exposure_names

A character vector of two named binary exposure variables present in the fitted model: the default is an empty vector. If effect modification is being assessed, to get the right orientation of the table output, the first variable should be the putative effect modifier, the second, the main exposure. If it's interaction, the order doesn't matter.

ci.type

A character string ("delta" or "mover") specifying the method to use for the estimation of CI for the measures of additive interaction. Default is "delta".

ci.level

Magnitude of the returned CI level. Default is 0.95

em

TRUE (the default), for effect modification assessment. FALSE, for interaction.

recode

If TRUE, recodes the exposures - if at least one of the exposures is protective - such that the stratum with the lowest risk becomes the new reference category when the two exposures are considered jointly.

Details

Effect modification is assessed when the effect of an exposure on an outcome differs within the strata of another exposure, while, the assessment of the joint effect of two exposures on outcome is Interaction. Both terms are often used interchangeably in the literature.

Despite the widespread analysis of interaction in the literature, the reporting is inadequate. To remedy this, Knol and Vanderweele (2012) proposed a set of recommendations that ensures full reporting for readers to be able to assess all dimensions of interaction. The function returns all the effect estimates to fulfill these recommendations.

Also, assessment of interaction is scale dependent: multiplicative or additive. Interaction on a multiplicative scale means that the combined effect of the two exposures is greater (or less) than the product of the individual effects of the two exposures. Interaction on an additive scale means that the combined effect of two exposures is greater (or less) than the sum of the individual effects of two exposures. Whereas, interaction on the additive scale is more relevant to public health, most authors merely report on the multiplicative scale. The recommendations mentioned above ensures reporting on both scales.

This function calculates three indices to assess the presence of additive interaction, as defined by Rothman (1998): (1) the relative excess risk due to interaction (RERI), (2) the proportion of disease among those with both exposures that is attributable to their interaction (AP), and (3) the synergy index (SI). A RERI or AP of zero means no interaction or perfect additivity. A RERI or AP of greater than zero means positive interaction or more than additivity. A RERI or AP of less than zero means negative interaction or less than additivity. RERI ranges from zero to infinity while AP ranges from -1 to +1.

The synergy index is the ratio of the combined effects and the individual effects. An SI of one means no interaction or perfect additivity. An SI of greater than one means positive interaction or more than additivity. An SI of less than one means negative interaction or less than additivity. SI ranges from zero to infinity.

The delta method as described by Hosmer and Lemeshow (1992) is the most widely used method to calculate the confidence intervals of these interaction measures and the provides this function. However, the poor performance of this method for typical use-cases is well documented. Therefore, the function also provides the option for these CIs estimations with the better performing MOVER method introduced by Zou (2008).

Finally, additive interaction as described by Rothman (1998) assumes that the two exposures under study are risk factors for the outcome (i.e. RR > 1). As shown by Knol et al. (2012), If at least one of the two exposures are preventive (i.e. RR < 1) then estimates of RERI and AP becomes invalid (the SI is unaffected), and the exposures need to be recoded to risk factors such that stratum with the lowest risk becomes the new reference category when the two exposures are considered together. The function can automatically carry out this recoding.

Value

a list object of class 'interactionR' that includes a dataframe containing all effect estimates necessary for full reporting of effect modification or interaction analysis. @seealso interactionR_table for how to generate a publication-ready table from this object.

References

Knol MJ, VanderWeele TJ. Recommendations for presenting analyses of effect modification and interaction. Int J Epidemiol 2012; 41:514-20.

Hosmer DW, Lemeshow S. Confidence interval estimation of interaction. Epidemiology 1992; 3:452-6.

Zou GY. On the Estimation of Additive Interaction by Use of the Four-by-two Table and Beyond. American Journal of Epidemiology 2008; 168:212-24.

Rothman K, Greenland S (1998). Modern Epidemiology. Lippincott - Raven Philadelphia, USA.

Knol, M.J., VanderWeele, T.J., Groenwold, R.H.H. et al. Estimating measures of interaction on an additive scale for preventive exposures. Eur J Epidemiol 26, 433–438 (2011). https://doi.org/10.1007/s10654-011-9554-9

Examples

## Using Case-control data from Rothman and Keller (1972)
## evaluating the joint effect of alcohol and smoking
## on oral cancer risk is included in the package
## (cited in Hosmer and Lemeshow (1992) and Zou (2008))
## fit the interaction model
model.glm <- glm(oc ~ alc * smk,
  family = binomial(link = "logit"),
  data = OCdata
)

## Then pass the fitted model to the function
interactionR(model.glm,
  exposure_names = c("alc", "smk"),
  ci.type = "delta", ci.level = 0.95,
  em = FALSE, recode = FALSE
)

## Because the delta method was selected, the returned CI for the trio
## of interaction measures is as reported in page 455 of Hosmer and Lemeshow (1992) for this dataset

## To get CIs using the variance recovery method, set the 'ci.type' to "mover"
interactionR(model.glm,
  exposure_names = c("alc", "smk"),
  ci.type = "mover", ci.level = 0.95,
  em = FALSE, recode = FALSE
)
## Now the CI returned for RERI is as Figure 4 in Zou (2008)

## To demonstrate the recoding feature of the function
## We simulate a dataset with three binary variables: one outcome and two preventive exposures

## Generate exposure variables
n <- 2000
set.seed(750)
exp1 <- rbinom(n, size = 1, p = 0.2)
set.seed(520)
exp2 <- rbinom(n, size = 1, p = 0.6)

## Make at least one of the exposures preventive for the outcome
b0 <- log(1)
bexp1 <- log(0.4)
bexp2 <- log(1.1)
bexp1exp2 <- log(0.75)

## Generate outcome
ppred <- b0 + bexp1 * exp1 + bexp2 * exp2 + bexp1exp2 * exp1 * exp2
p <- exp(ppred) / (1 + exp(ppred))
set.seed(30)
outcome <- rbinom(n, size = 1, p = p)

## Create dataframe
d <- data.frame(outcome, exp1, exp2)

## Fit a logistic regression model with the data
model.prev <- glm(outcome ~ exp1 * exp2, family = binomial(link = "logit"), data = d)

## With this model, calling the function with the default FALSE parameter for
## the 'recode' argument returns an error
## And informs the user to set 'recode' to TRUE if they want to automatically recode the variables
## Set to TRUE, the function recodes the data and generate estimates
## for additive interaction measures with the new data which
## can be examined in the returned list object by the function

interactionR(model.prev,
  exposure_names = c("exp1", "exp2"),
  ci.type = "delta", ci.level = 0.95,
  em = FALSE, recode = TRUE
)

Confidence intervals for interaction measures using bootstrapping as described by Assmann et al (1996).

Description

Confidence intervals for interaction measures using bootstrapping as described by Assmann et al (1996).

Usage

interactionR_boot(
  model,
  ci.level = 0.95,
  em = T,
  recode = F,
  seed = 12345,
  s = 1000
)

Arguments

model

A fitted model object of class glm. Requires that the two binary exposure variables are listed first in the call formula.

ci.level

Magnitude of the returned CI level. Default is 0.95

em

TRUE (the default), for effect modification assessment. FALSE, for interaction.

recode

If TRUE, recodes the exposures - if at least one of the exposures is protective - such that the stratum with the lowest risk becomes the new reference category when the two exposures are considered jointly.

seed

The random seed to use for generating the bootstrap samples for confidence intervals (for reproducibility). Default is 12345, but can be set to any number.

s

Number of bootstrap resampling. Default is 1000

Value

a list object of class 'interactionR' that includes a dataframe containing all effect estimates necessary for full reporting of effect modification or interaction analysis. @seealso interactionR_table for how to generate a publication-ready table from this object.

References

Assmann SF, Hosmer DW, Lemeshow S, Mundt KA. Confidence intervals for measures of interaction. Epidemiology 1996:286-90.

Examples

## Model fitting using dataset from assmann et al.
## The data is available in the package.
m <- glm(h ~ ns * smk,
  family = binomial(link = "logit"),
  data = HDiscdata
)

interactionR_boot(m,
  ci.level = 0.95, em = FALSE, recode = FALSE,
  seed = 12345, s = 1000
)

Computes confidence intervals for interaction measures using the delta method by Hosmer and Lemeshow

Description

Computes confidence intervals for interaction measures using the delta method by Hosmer and Lemeshow

Usage

interactionR_delta(
  model,
  exposure_names = c(),
  ci.level = 0.95,
  em = T,
  recode = F
)

Arguments

model

A fitted model object of class glm, clogit or coxph

exposure_names

A character vector of two named binary exposure variables present in the fitted model: the default is an empty vector. If effect modification is being assessed, to get the right orientation of the table output, the first variable should be the putative effect modifier, the second, the main exposure. If it's interaction, the order doesn't matter.

ci.level

Magnitude of the returned CI level. Default is 0.95

em

TRUE (the default), for effect modification assessment. FALSE, for interaction.

recode

If TRUE, recodes the exposures - if at least one of the exposures is protective - such that the stratum with the lowest risk becomes the new reference category when the two exposures are considered jointly.

Value

a list object of class 'interactionR' that includes a dataframe containing all effect estimates necessary for full reporting of effect modification or interaction analysis. @seealso interactionR_table for how to generate a publication-ready table with this object.

Examples

## Using Case-control data from Rothman and Keller (1972)
## evaluating the joint effect of alcohol and smoking
## on oral cancer risk is included in the package
## (cited in Hosmer and Lemeshow (1992) and Zou (2008))

## fit the interaction model
model.glm <- glm(oc ~ alc * smk,
  family = binomial(link = "logit"),
  data = OCdata
)

## Then pass the fitted model to the function
interactionR_delta(model.glm,
  exposure_names = c("alc", "smk"),
  ci.level = 0.95, em = FALSE, recode = FALSE
)

Computes confidence intervals for interaction measures using the variance recovery method by Zou (2018)

Description

Computes confidence intervals for interaction measures using the variance recovery method by Zou (2018)

Usage

interactionR_mover(
  model,
  exposure_names = c(),
  ci.level = 0.95,
  em = T,
  recode = F
)

Arguments

model

A fitted model object of class glm, clogit or coxph

exposure_names

A character vector of two named binary exposure variables present in the fitted model: the default is an empty vector. If effect modification is being assessed, to get the right orientation of the table output, the first variable should be the putative effect modifier, the second, the main exposure. If it's interaction, the order doesn't matter.

ci.level

Magnitude of the returned CI level. Default is 0.95

em

TRUE (the default), for effect modification assessment. FALSE, for interaction.

recode

If TRUE, recodes the exposures - if at least one of the exposures is protective - such that the stratum with the lowest risk becomes the new reference category when the two exposures are considered jointly.

Value

a list object of class 'interactionR' that includes a dataframe containing all effect estimates necessary for full reporting of effect modification or interaction analysis. @seealso interactionR_table for how to generate a publication-ready table with this object.

Examples

## Using Case-control data from Rothman and Keller (1972)
## evaluating the joint effect of alcohol and smoking
## on oral cancer risk is included in the package
## (cited in Hosmer and Lemeshow (1992) and Zou (2008))

## fit the interaction model
model.glm <- glm(oc ~ alc * smk,
  family = binomial(link = "logit"),
  data = OCdata
)

## Then pass the fitted model to the function
interactionR_mover(model.glm,
  exposure_names = c("alc", "smk"),
  ci.level = 0.95, em = FALSE, recode = FALSE
)

Publication-ready tables for effect modification and interaction analysis

Description

Generates a publication-ready table for effect modification and interaction analysis based on Tables 1 and 3 in Knol and Vanderweele (2012) [doi:10.1093/ije/dyr218]. Users can modify the function's output like any flextable object @seealso flextable. The confidence intervals for additive interaction measures will be as selected from the interactionR function

Usage

interactionR_table(obj, p.value = FALSE, file_path = NA)

Arguments

obj

An object of class 'interactionR' generated from any of the main functions in the interactionR package

p.value

Includes p-values in the generated table if set to TRUE. Default is FALSE.

file_path

An optional user-specified string representing the file path to save the generated Word table instead of the current working directory

Value

saves a publication-ready microsoft word Table corresponding to Table 1 or Table 3 respectively in Knol and Vanderweele (2012) to the working directory (with user's permission). It also returns an object of class flextable corresponding to the saved table for further manipulation.

Examples

library(interactionR)
data(OCdata)

## fit the interaction model
model.glm <- glm(oc ~ alc * smk,
  family = binomial(link = "logit"),
  data = OCdata
)
## Then pass the fitted model to the main function
value <- interactionR(model.glm,
  exposure_names = c("alc", "smk"),
  ci.type = "delta", ci.level = 0.95,
  em = FALSE, recode = FALSE
)

## Use the tabling function to generate a table
interactionR_table(value)

Case-control study of the joint effect of alcohol and smoking on oral cancer by Rothman and Keller.

Description

A dataset containing three dichotomous variables: oral cancer, alcohol and smoking

Usage

OCdata

Format

A data frame with 458 observations and 3 variables:

oc

oral cancer, the outcome

alc

alcohol use, the first exposure

smk

smoking, the second exposure

...

Source

doi:10.1016/0021-9681(72)90006-9