massLMorLVM: Multiple Linear Regressions or Single LVM

View source: R/massLMorLVM.R

massLMorLVMR Documentation

Multiple Linear Regressions or Single LVM

Description

Multiple Linear Regressions or Single LVM

Usage

massLMorLVM(formula, data, exposure, outcomes = NULL, ...)

Arguments

formula

[formula or list of formula] formula whose right hand side indicates the covariantes. The left hand side is ignored.

data

[data.frame] dataset

exposure

[character] the name of one variable in the formula whose effect should be assessed.

outcomes

[character vector] name of the outcomes.

...

arguments passed to glht2.

Examples

## Not run: 
mSim <- lvm(c(Y1,Y2,Y3,Y4,Y5) ~ 2*eta + age, eta ~ E)
categorical(mSim, labels = c("yes","no")) <- ~E
latent(mSim) <- ~eta

d <- lava::sim(mSim, n = 1e2, latent = FALSE)

out <- massLMorLVM(~age+E, data = d, exposure = "E",
                   outcomes = c("Y1","Y2","Y3","Y4","Y5"))

summary(out$model$lm[[1]])$coefficient["Eno",,drop=FALSE]
summary(out$model$lvm)$coef["Y1~Eno",,drop=FALSE]
c(var.lm = sigma(out$model$lm[[1]])^2,
  var.lvm = as.double(coef(out$model$lvm)["Y1~~Y1"] + coef(out$model$lvm)["eta~~eta"]))

lapply(out$glht, summary)

dL <- melt(cbind(id = 1:NROW(d),d), id.vars = c("id","E","age"))
dL$variable <- as.factor(dL$variable)
e.gls <- gls(value ~ variable*E + variable*age,
             correlation = corSymm(form =~ as.numeric(variable)|id),
             weights = varIdent(form =~ 1|variable),
             data = dL)
summary(e.gls)$tTable

## End(Not run)


bozenne/butils documentation built on Oct. 14, 2023, 6:19 a.m.