# NOT RUN {
N <- 20 # number of groups
p <- 20 # number of covariates (including intercept)
q <- 2 # number of random effect covariates
ni <- rep(6,N) # observations per group
n <- sum(ni) # total number of observations
grp <- factor(rep(1:N,ni)) # grouping variable
grp=rbind(grp,grp)
beta <- c(1,2,4,3,rep(0,p-3)) # fixed-effects coefficients
x <- cbind(1,matrix(rnorm(n*p),nrow=n)) # design matrix
u1=rnorm(N,0,sd=sqrt(2))
u2=rnorm(N,0,sd=sqrt(2))
bi1 <- rep(u1,ni)
bi2 <- rep(u2,ni)
bi <- rbind(bi1,bi2)
z=x[,1:2,drop=FALSE]
epsilon=rnorm(120)
y <- numeric(n)
for (k in 1:n) y[k] <- x[k,]%*%beta + t(z[k,])%*%bi[,k] + epsilon[k]
######
fit0=lmme(x[,1:4],y,z,grp)
fit1=lassop(x,y,z,grp,mu=0.2,fix=1,rand=c(1,2))
#fit1=lassop(x,y,z,grp,mu=0.2,fix=1,rand=c(1,2),showit=TRUE)
fit2=mhtp(x,y,z,grp,fix=1,rand=c(1,2),alpha=0.1,num=15)
#fit2=mhtp(x,y,z,grp,fix=1,rand=c(1,2),alpha=0.1,num=15,show=c(1,1,1))
# }
Run the code above in your browser using DataLab