test.varcomp: Testing Zero Variance Components in Linear Mixed Models

Description Usage Arguments Value Author(s) References See Also Examples

View source: R/test.varcomp.R

Description

test.varcomp tests whether certain variance components are zeros. This function provides a formula interface to the rlr.test function.

Usage

1
2
3
test.varcomp(fixed, random, test, data = NULL, Sigma = NULL, 
  type = "RLR", nsim = 5000L, seed = 130623L, 
  keep.matrices = FALSE)

Arguments

fixed

a two-sided formula specifying the response and the fixed effects.

random

a one-sided formula specifying the random effects (not including the error term).

test

an integer vector of the indices of random effects to be tested.

data

an optional data frame, list or environment containing the variables in the model.

Sigma

an optional list of symmetric and positive definite matrices specifying the correlation structures of random effects. If NULL, default to identity matrices.

type

RLR for restricted likelihood ratio test and generalized F-test

nsim

number of simulations from the null distribution.

seed

a seed to be set before simulating from the null distribution.

keep.matrices

whether the design matrices for fixed effects and random effects, as well as the response vector, will be returned.

Value

A list containing the following components:

RLRT

A vector of the test statistic and the p-value of restricted likelihood ratio test.

GFT

A vector of the test statistic and the p-value of generalized F-test.

Y

If keep.matrices is TRUE, the response.

X

If keep.matrices is TRUE, the fixed effects design matrix.

Z

If keep.matrices is TRUE, a list of the random effects design matrices.

Sigma

If keep.matrices is TRUE, a list of the random effects correlation structures.

Author(s)

Yichi Zhang

References

Zhang, Y., Staicu, A.-M., and Maity, A. (2016). Testing for additivity in non-parametric regression. Canadian Journal of Statistics, 44: 445-462. doi: 10.1002/cjs.11295

See Also

rlr.test

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
n1 <- 5L
n2 <- 6L
n0 <- 4L
A <- gl(n1, n2 * n0)
B <- rep(gl(n2, n0), n1)
set.seed(1L)
Y <- 1 + rnorm(n1, 0, 0.7)[A] + rnorm(n2, 0, 0.3)[B] + 
  rnorm(n1 * n2, 0, 0.5)[A : B] + rnorm(n1 * n2 * n0, 0, 1)
test.varcomp(Y ~ 1, ~ -1 + A + B + A:B, test = c(2L, 3L), 
  nsim = 2000L, seed = 2L)

lmeVarComp documentation built on May 2, 2019, 8:55 a.m.