example_2way_lme4 {LEGIT}R Documentation

Simulated example of a 3 way interaction GxExZ model

Description

Simulated example of a 3 way interaction GxExZ model (where G, E and Z are latent variables).

gjBinomial(n=1,p=.30)g_j \sim Binomial(n=1,p=.30)

j=1,2,3,4j = 1, 2, 3, 4

ekNormal(μ=0,σ=1.5)e_k \sim Normal(\mu=0,\sigma=1.5)

k=1,2,3k = 1, 2, 3

zlNormal(μ=3,σ=1)z_l \sim Normal(\mu=3,\sigma=1)

l=1,2,3l = 1, 2, 3

g=.2g1+.15g2.3g3+.1g4+.05g1g3+.2g2g3g = .2g_1 + .15g_2 - .3g_3 + .1g_4 + .05g_1g_3 + .2g_2g_3

e=.45e1+.35e2+.2e3e = -.45e_1 + .35e_2 + .2e_3

z=.15z1+.60z2+.25z3z = .15z_1 + .60z_2 + .25z_3

μ=2+2g+3e+z+5ge1.5ez+2gz+2gez\mu = -2 + 2g + 3e + z + 5ge - 1.5ez + 2gz + 2gez

yNormal(μ=μ,σ=sigma)y \sim Normal(\mu=\mu,\sigma=\code{sigma}) if logit=FALSE
yBinomial(n=1,p=logit(μ))y \sim Binomial(n=1,p=logit(\mu)) if logit=TRUE

Usage

example_2way_lme4(N, sigma = 1, logit = FALSE, seed = NULL)

Arguments

N

Sample size.

sigma

Standard deviation of the gaussian noise (if logit=FALSE).

logit

If TRUE, the outcome is transformed to binary with a logit link.

seed

RNG seed.

Value

Returns a list containing, in the following order: data.frame with the observed outcome (with noise) and the true outcome (without noise), list containing the data.frame of the genetic variants (G), the data.frame of the ee environments (E) and the data.frame of the zz environments (Z), vector of the true genetic coefficients, vector of the true ee environmental coefficients, vector of the true zz environmental coefficients, vector of the true main model coefficients

Examples

# Doing only one iteration so its faster
train = example_2way_lme4(250, 1, seed=777)
D = train$data
G = train$G
E = train$E

F = y ~ G*E
fit = LEGIT(D, G, E, F, lme4=FALSE, maxiter=1)
summary(fit)
F = y ~ 1
fit_test = GxE_interaction_test(D, G, E, F, criterion="AIC", lme4=FALSE, maxiter=1)
fit_test
#fit_test = GxE_interaction_test(D, G, E, F, criterion="cv", lme4=FALSE, maxiter=1, cv_iter=1)
#fit_test

F = y ~ G*E + (1|subject)
fit = LEGIT(D, G, E, F, lme4=TRUE, maxiter=1)
summary(fit)
F = y ~ (1|subject)
fit_test = GxE_interaction_test(D, G, E, F, criterion="AIC", lme4=TRUE, maxiter=1)
fit_test
#fit_test = GxE_interaction_test(D, G, E, F, criterion="cv", lme4=TRUE, maxiter=1, cv_iter=1)
#fit_test

[Package LEGIT version 1.4.1 Index]