model_estimate: Model estimation

View source: R/model_estimate.R

model_estimateR Documentation

Model estimation

Description

This function gives the model estimates.

Usage

model_estimate(
  X,
  M,
  Y,
  I_update,
  tol = 10^(-10),
  max.iter = 10,
  lambda1 = exp(1),
  lambda2 = exp(-1),
  alpha = 1,
  penalty.factor = c(1, rep(1, ncol(M) * 2), rep(1, max(0, ncol(I_update)))),
  verbose = FALSE,
  Omega.out = FALSE
)

Arguments

X

one-dimensional exposure

M

multivariate mediators

Y

one-dimensional outcome

I_update

interaction term

tol

convergence criterion (default = -10^(-10))

max.iter

maximum iteration (default = 10)

lambda1

tuning parameter for regression coefficient L1 penalization

lambda2

tuning parameter for covariance-inverse matrix

alpha

alpha in glmnet() (default = 1: lasso penalty)

penalty.factor

penalty factor vector, in the order of (c,b1,b2,a)

verbose

print progress (default = FALSE)

Omega.out

output Omega estimates (default = FALSE)

Value

c: direct effect estimate

hatb1: path b1 (M->Y given X) estimates

hatb2: path b2 (X*M->Y) estimates

hata: path a (X->M) estimates

nump: number of selected paths + 1 direct effect

Omega: estimated covariance-inverse matrix of the mediators

sigmasq: estimated variance of the outcome

Examples

data = dat_gen(N = 400, V = 50, es = 1, seed = 1234)
X = data$X; Y = data$Y; M = data$M; I = X*M
model_estimate(X, M, Y, I, lambda1 = 0.2, lambda2 = 0.1, alpha = 1, Omega.out = F)

ruiyangli1/XMInt documentation built on March 18, 2024, 12:13 p.m.