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