Skip to contents

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)
#> $c
#> [1] 0.2128745
#> 
#> $hatb1
#>        M1        M2        M3        M4        M5        M6        M7        M8 
#> 0.2659559 0.3007976 0.2562496 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 
#>        M9       M10       M11       M12       M13       M14       M15       M16 
#> 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 
#>       M17       M18       M19       M20       M21       M22       M23       M24 
#> 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 
#>       M25       M26       M27       M28       M29       M30       M31       M32 
#> 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 
#>       M33       M34       M35       M36       M37       M38       M39       M40 
#> 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 
#>       M41       M42       M43       M44       M45       M46       M47       M48 
#> 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 
#>       M49       M50 
#> 0.0000000 0.0000000 
#> 
#> $hatb2
#>        M1        M2        M3        M4        M5        M6        M7        M8 
#> 0.2005432 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 
#>        M9       M10       M11       M12       M13       M14       M15       M16 
#> 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 
#>       M17       M18       M19       M20       M21       M22       M23       M24 
#> 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 
#>       M25       M26       M27       M28       M29       M30       M31       M32 
#> 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 
#>       M33       M34       M35       M36       M37       M38       M39       M40 
#> 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 
#>       M41       M42       M43       M44       M45       M46       M47       M48 
#> 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 
#>       M49       M50 
#> 0.0000000 0.0000000 
#> 
#> $hata
#>        M1        M2        M3        M4        M5        M6        M7        M8 
#> 0.6152488 0.6075804 0.6628388 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 
#>        M9       M10       M11       M12       M13       M14       M15       M16 
#> 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 
#>       M17       M18       M19       M20       M21       M22       M23       M24 
#> 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 
#>       M25       M26       M27       M28       M29       M30       M31       M32 
#> 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 
#>       M33       M34       M35       M36       M37       M38       M39       M40 
#> 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 
#>       M41       M42       M43       M44       M45       M46       M47       M48 
#> 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 
#>       M49       M50 
#> 0.0000000 0.0000000 
#> 
#> $nump
#> [1] 8
#> 
#> $Omega
#> NULL
#> 
#> $sigmasq
#> [1] 0.08324613
#>