Learn R Programming

lavaSearch2 (version 1.4)

glht2: General Linear Hypothesis

Description

Test general linear hypotheses and across latent variable models with small sample corrections.

Usage

glht2(model, linfct, rhs, bias.correct, df, robust, cluster)

# S3 method for lvmfit glht2(model, linfct, rhs = 0, bias.correct = TRUE, df = TRUE, robust = FALSE, cluster = NULL)

# S3 method for mmm glht2(model, linfct, rhs = 0, bias.correct = TRUE, df = TRUE, robust = FALSE, cluster = NULL)

Arguments

model

a lvmfit or mmm object. The mmm object can only contain lm/gls/lme/lvmfit objects.

linfct

[matrix or vector of character] the linear hypotheses to be tested. Same as the argument par of createContrast.

rhs

[vector] the right hand side of the linear hypotheses to be tested.

bias.correct

[logical] should the standard errors of the coefficients be corrected for small sample bias?

df

[logical] should the degree of freedoms of the Wald statistic be computed using the Satterthwaite correction?

robust

[logical] should robust standard error be used? Otherwise rescale the influence function with the standard error obtained from the information matrix.

cluster

[integer vector] the grouping variable relative to which the observations are iid.

Value

A glht object.

Details

Whenever the argument linfct is not a matrix, it is passed to the function createContrast to generate the contrast matrix and, if not specified, rhs.

Since only one degree of freedom can be specify in a glht object and it must be an integer, the degree of freedom of the denominator of an F test simultaneously testing all hypotheses is retained, after rounding.

Argument rhs and null are equivalent. This redondance enable compatibility between lava::compare, compare2, multcomp::glht, and glht2.

See Also

createContrast to create contrast matrices. sCorrect to pre-compute quantities for the small sample correction.

Examples

Run this code
# NOT RUN {
library(multcomp)

## Simulate data
mSim <- lvm(c(Y1,Y2,Y3)~ beta * eta, Z1 ~ E, Z2 ~ E, Age[40:5]~1)
latent(mSim) <- "eta"
set.seed(10)
n <- 1e2

df.data <- lava::sim(mSim, n, latent = FALSE, p = c(beta = 1))

#### Inference on a single model ####
e.lvm <- estimate(lvm(Y1~E), data = df.data)
summary(glht2(e.lvm, linfct = c("Y1~E + Y1","Y1")))

#### Inference on separate models ####
## fit separate models
lmX <- lm(Z1 ~ E, data = df.data)
lvmY <- estimate(lvm(Z2 ~ E + Age), data = df.data)
lvmZ <- estimate(lvm(c(Y1,Y2,Y3) ~ eta, eta ~ E), 
                 data = df.data)

#### create mmm object #### 
e.mmm <- mmm(X = lmX, Y = lvmY, Z = lvmZ)

#### create contrast matrix ####
resC <- createContrast(e.mmm, var.test = "E", add.variance = TRUE)

#### adjust for multiple comparisons ####
e.glht2 <- glht2(e.mmm, linfct = resC$contrast)
summary(e.glht2)

# }

Run the code above in your browser using DataLab