Learn R Programming

lavaSearch2 (version 1.0.0)

lTest: Compute the Degree of Freedom of the Variance Parameters

Description

Compute the degree of freedom of the variance parameters.

Usage

lTest(object, ...)

# S3 method for lm lTest(object, C = NULL, adjust.residuals = TRUE, Ftest = TRUE, ...)

# S3 method for gls lTest(object, C = NULL, adjust.residuals = TRUE, Ftest = TRUE, ...)

# S3 method for lme lTest(object, C = NULL, adjust.residuals = TRUE, Ftest = TRUE, ...)

# S3 method for lvmfit lTest(object, C = NULL, adjust.residuals = TRUE, Ftest = TRUE, ...)

Arguments

object

a lvm object.

...

arguments to be passed to dVcov2.

C

[optional] a contrast matrix.

adjust.residuals

should a small-sample correction be used when computing the variance of the parameters and the degree of freedoms.

Ftest

should a join test be computed.

Details

In the case of a lm object, the contrast matrix need not to contain a column for the variance parameter when the columns are named. When so, a column containing 0 is added to the contrast matrix.

Examples

Run this code
# NOT RUN {
set.seed(10)
mSim <- lvm(Y~0.1*X1+0.2*X2)
categorical(mSim, labels = c("a","b","c")) <- ~X1
transform(mSim, Id~Y) <- function(x){1:NROW(x)}
df.data <- lava::sim(mSim, 1e2)

## gold standard
e.lm <- lm(Y~X1+X2, data = df.data)
anova(e.lm)

lTest(e.lm)

## gls model
library(nlme)
e.gls <- gls(Y~X1+X2, data = df.data, method = "ML")
e.gls$dVcov <- dVcov2(e.gls, data = df.data, cluster = df.data$Id)

C <- rbind(c(0,1,0,0,0),c(0,0,1,0,0))
colnames(C) <- names(attr(e.gls$dVcov,"param"))
lTest(e.gls, data = df.data, C = C)

C <- rbind(c(0,0,0,1,0))
colnames(C) <- names(attr(e.gls$dVcov,"param"))
lTest(e.gls, data = df.data, C = C)

## latent variable model
m <- lvm(Y~X1+X2)
e.lvm <- estimate(m, df.data)
e.lvm$dVcov <- dVcov2(e.lvm)

C <- rbind(c(0,0,1,0,0),c(0,0,0,1,0))
colnames(C) <- names(coef(e.lvm))
lTest(e.lvm, C = C)

C <- rbind(c(0,1,0,0,0))
colnames(C) <- names(coef(e.lvm))
lTest(e.lvm, C = C)

# }

Run the code above in your browser using DataLab