Learn R Programming

CLME (version 1.0-1)

lrt.stat: Likelihood Ratio Type Test Statistic.

Description

Calculates the likeihood ratio type test statistic (under Normality assumption) for a constrained linear mixed effects model. This is the default test statistic for CLME.

Usage

lrt.stat( theta , A , Y , X1 , X2 , U , tsq , ssq , Nks , Qs , ... )

Arguments

theta
estimated coefficients.
A
matrix of linear constraints.
Y
$N \times 1$ vector of response data.
X1
$N \times p_1$ design matrix.
X2
$N \times p_2$ matrix of covariates.
U
$N \times c$ matrix of random effects.
tsq
estimate of random effect variance (may be vector).
ssq
estimate of residual variance (may be vector).
Nks
$K \times 1$ vector of group sizes.
Qs
$Q \times 1$ vector of group sizes for random effects.
...
additional arguments, to enable custom test statistic functions.

Value

  • Output is a numeric scalar.

See Also

w.stat,

Examples

Run this code
set.seed( 42 )

n  <- 5
P1 <- 5

X1 <- diag(P1) %x% rep(1,n)
X2 <- as.matrix( rep(1,P1) %x% runif(n , 0,2) )
U  <- rep(1,P1) %x% diag(n)
X  <- as.matrix( cbind(X1,X2) )

tsq <- 1
ssq <- 0.7

Nks <- dim(X1)[1]
Qs  <- dim(U)[2]

xi <- rnorm( sum(Qs)  , 0 , rep(sqrt(tsq) , Qs)  )
ep <- rnorm( sum(Nks) , 0 , rep(sqrt(ssq) , Nks) )  

thetas <- c(2 , 3 , 3, 3 , 4 , 2 )
Y      <- X%*%thetas + U%*%xi + ep
const  <- create.constraints( X1=X1 , X2=X2 , 
          constraints=list(order='simple' , decreasing=FALSE) )

# Estimate parameters (also computed lrt statistic: ts.glb)
clme.out <- clme.em.all( method='QPE', Y=Y, X1=X1, X2=X2, U=U,
                     constraints=const, tsf=lrt.stat )

# Individually compute lrt statistic
lrt.stat( clme.out$theta , const$A , Y , X1 , X2 , 
          U , clme.out$tsq , clme.out$ssq , Nks , Qs )

Run the code above in your browser using DataLab