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
# Assume homogeneity of variances and no covariates or random effects
minque( Y=Y , X1=X1 )
# Assume homogeneity of variances and include covariates and random effects
minque( Y=Y , X1=X1 , X2=X2 , U=U )
# Assume heterogeneity of variances, and include random effects
minque( Y=Y , X1=X1 , X2=X2 , U=U , Nks=Nks , Qs=Qs )
Run the code above in your browser using DataLab