neLht: Linear hypotheses for natural effect models

neLhtR Documentation

Linear hypotheses for natural effect models

Description

neLht allows to calculate linear combinations of natural effect model parameter estimates.
neEffdecomp automatically extracts relevant causal parameter estimates from a natural effect model.

Usage

neEffdecomp(model, xRef, covLev, ...)

## S3 method for class 'neModel'
neEffdecomp(model, xRef, covLev, ...)

neLht(model, ...)

## S3 method for class 'neModel'
neLht(model, ...)

Arguments

model

a fitted natural effect model object.

xRef

a vector including reference levels for the exposure, x* and x, at which natural effect components need to be evaluated (see details).

covLev

a vector including covariate levels at which natural effect components need to be evaluated (see details).

...

additional arguments (passed to glht).

Details

neLht is a wrapper of glht and offers the same functionality (see ‘Details’ section of glht for details on argument specification). It returns objects that inherit from the class "neLht" in order to make output of their corresponding methods (see neLht-methods) more compatible for natural effect models containing bootstrap variance-covariance matrices and standard errors.

neEffdecomp is a convenience function that automatically extracts causal parameter estimates from a natural effect model and derives natural effect components. That is, natural direct, natural indirect and total causal effect estimates are returned if no exposure-mediator interaction is modelled (i.e. two-way decomposition). If mediated interaction is allowed for in the natural effect model, there are two ways of decomposing the total effect into (natural) direct and indirect effects components: either as the sum of the pure direct and the total indirect effect or as the sum of the pure indirect and the total direct effect (i.e. three-way decomposition). In total, five causal effect estimates are returned in this case.

For continuous exposures, default exposure levels at which natural effect components are evaluated are x* = 0 and x = 1. For multicategorical exposures, default levels are the reference level of the factor that encodes the exposure variable and the level corresponding to its first dummy variable for x* and x, respectively. If one wishes to evaluate natural effect components at different reference levels (e.g. if the natural effect model includes mediated interaction, quadratic or higher-order polynomial terms for the exposure; see examples), these can be specified as a vector of the form c(x*,x) via the xRef argument.

If applicable, covariate levels at which natural effect components are evaluated can also be specified. This is particularly useful for natural effect models encoding effect modification by baseline covariates (e.g. moderated mediation). By default, these levels are set to 0 for continuous covariates and to the reference level for categorical covariates coded as factors. Different covariate levels can be specified via the covLev argument, which requires a vector including valid levels for covariates that are specified in the natural effect model (or a subset of covariates that are specified as modifiers of either the natural direct or indirect effect or both). Levels need to be preceded by the name of the corresponding covariate, e.g., covLev = c(gender = "M", age = 30). Covariates for which the levels are left unspecified are set to their default levels (see examples). The print and summary functions for neEffdecomp objects return the covariate levels at which natural effect components are evaluated. No specific levels are returned for covariates that are not specified as modifier since effect decomposition is independent of the level of these covariates (see examples).

Value

An object of class c("neLht", "glht") (see glht). If the bootstrap is used for obtaining standard errors when fitting the neModel object, the returned object additionally inherits from class "neLhtBoot". neEffdecomp returns an object that additionally inherits from class "neEffdecomp".

See neLht-methods for methods for neLht objects (and glht-methods for additional methods for glht objects).

Note

neEffdecomp is internally called by plot.neModel to create confidence interval plots for neModel objects.

See Also

plot.neLht, neLht-methods, glht, glht-methods, neModel, plot.neModel, summary

Examples

data(UPBdata)

impData <- neImpute(UPB ~ att * negaff + gender + educ + age, 
                    family = binomial, data = UPBdata)
neMod <- neModel(UPB ~ att0 * att1 + gender + educ + age, 
                 family = binomial, expData = impData, se = "robust")

lht <- neLht(neMod, linfct = c("att0 = 0", "att0 + att0:att1 = 0", 
                               "att1 = 0", "att1 + att0:att1 = 0", 
                               "att0 + att1 + att0:att1 = 0"))
summary(lht)

## or obtain directly via neEffdecomp
eff <- neEffdecomp(neMod)
summary(eff)

## changing reference levels for multicategorical exposures
UPBdata$attcat <- factor(cut(UPBdata$att, 3), labels = c("L", "M", "H"))
impData <- neImpute(UPB ~ attcat * negaff + gender + educ + age,
                    family = binomial, data = UPBdata)
neMod <- neModel(UPB ~ attcat0 * attcat1 + gender + educ + age,
                 family = binomial, expData = impData, se = "robust")
                 
neEffdecomp(neMod)
neEffdecomp(neMod, xRef = c("L", "H"))
neEffdecomp(neMod, xRef = c("M", "H"))


## changing reference levels for continuous exposures
impData <- neImpute(UPB ~ (att + I(att^2)) * negaff + gender + educ + age,
                    family = binomial, data = UPBdata)
neMod <- neModel(UPB ~ (att0 + I(att0^2)) * (att1 + I(att1^2)) + gender + educ + age,
                 family = binomial, expData = impData, se = "robust")
neEffdecomp(neMod)
neEffdecomp(neMod, xRef = c(-1, 0))

## changing covariate levels when allowing for modification 
## of the indirect effect by baseline covariates
impData <- neImpute(UPB ~ (att + negaff + gender + educ + age)^2,
                    family = binomial, data = UPBdata)
neMod <- neModel(UPB ~ att0 * att1 + gender + educ + age + att1:gender + att1:age,
                 family = binomial, expData = impData, se = "robust")
neEffdecomp(neMod)
neEffdecomp(neMod, covLev = c(gender = "F", age = 0)) # default covariate levels
neEffdecomp(neMod, covLev = c(gender = "M", age = 40))
neEffdecomp(neMod, covLev = c(gender = "M", age = 40, educ = "L"))
neEffdecomp(neMod, covLev = c(gender = "M", age = 40, educ = "M"))
neEffdecomp(neMod, covLev = c(gender = "M", age = 40, educ = "H"))
# effect decomposition is independent of education level
neEffdecomp(neMod, covLev = c(gender = "M")) 
# age is set to its default level when left unspecified


jmpsteen/medflex documentation built on July 6, 2023, 8 p.m.