fit_mreg: Fit a model for the mediator given the treatment and...

View source: R/03_fit_mreg_mediator_modeling.R

fit_mregR Documentation

Fit a model for the mediator given the treatment and covariates.

Description

lm is called if mreg = "linear". glm is called with family = binomial() if mreg = "logistic".

Usage

fit_mreg(mreg, data, avar, mvar, cvar, emm_ac_mreg = NULL)

Arguments

mreg

A character vector of length 1. Mediator regression type: "linear" or "logistic".

data

Data frame containing the following relevant variables.

avar

A character vector of length 1. Treatment variable name.

mvar

A character vector of length 1. Mediator variable name.

cvar

A character vector of length > 0. Covariate names. Use NULL if there is no covariate. However, this is a highly suspicious situation. Even if avar is randomized, mvar is not. Thus, there are usually some confounder(s) to account for the common cause structure (confounding) between mvar and yvar.

emm_ac_mreg

A character vector of length > 0. Effect modifiers names. The covariate vector in treatment-covariate product term in the mediator model.

Value

A regression object of class lm (linear) or glm (logistic)


regmedint documentation built on April 7, 2022, 1:17 a.m.