Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

traditional_regression_functions

Traditional regression approaches.


Description

Functions to fit traditional regression approaches for a quantitative normally-distributed primary outcome (setting = "GLM") and a censoredtime-to-event primary outcome (setting = "AFT"). mult_reg fits the multiple regression approach and res_reg computes the regression of residuals approach.

Usage

mult_reg(setting = "GLM", Y = NULL, X = NULL, K = NULL, L = NULL,
  C = NULL)

res_reg(Y = NULL, X = NULL, K = NULL, L = NULL)

Arguments

setting

String with value "GLM" or "AFT" indicating whether the approaches are fitted for a normally-distributed primary outcome Y ("GLM") or a censored time-to-event primary outcome Y ("AFT"). Under the "AFT" setting, only mult_reg is available.

Y

Numeric input vector of the primary outcome.

X

Numeric input vector of the exposure variable.

K

Numeric input vector of the intermediate outcome.

L

Numeric input vector of the observed confounding factor.

C

Numeric input vector of the censoring indicator under the AFT setting (must be coded 0 = censored, 1 = uncensored).

Details

In more detail, for a quantitative normally-distributed primary outcome Y, mult_reg fits the model

Y = α0 + α1*K + αXY*X + α2*L + ε

and obtains point and standard error estimates for the parameters α0, α1, αXY, α2. res_reg obtains point and standard error estimates for the parameters α0, α1, α2, α3, αXY by fitting the models

Y = α0 + α1*K + α2*L + ε1,

hat(ε1) = α3 + αXY*X + ε2.

Both functions use the lm function and also report the provided p-values from t-tests that each parameter equals 0. For the analysis of a censored time-to-event primary outcome Y, only the multiple regression approach is implemented. Here, mult_reg fits the according censored regression model to obtain coefficient and standard error estimates as well as p-values from large-sample Wald-type tests by using the survreg function. See the vignette for more details.

Value

Returns a list with point estimates of the parameters point_estimates, standard error estimates SE_estimates and p-values pvalues.

Examples

dat_GLM <- generate_data(setting = "GLM")
mult_reg(setting = "GLM", Y = dat_GLM$Y, X = dat_GLM$X, K = dat_GLM$K,
         L = dat_GLM$L)
res_reg(Y = dat_GLM$Y, X = dat_GLM$X, K = dat_GLM$K, L = dat_GLM$L)

dat_AFT <- generate_data(setting = "AFT", a = 0.2, b = 4.75)
mult_reg(setting = "AFT", Y = dat_AFT$Y, X = dat_AFT$X, K = dat_AFT$K,
         L = dat_AFT$L, C = dat_AFT$C)

CIEE

Estimating and Testing Direct Effects in Directed Acyclic Graphs using Estimating Equations

v0.1.1
GPL-2
Authors
Stefan Konigorski [aut, cre], Yildiz E. Yilmaz [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.