# NOT RUN {
set.seed(1228)
n.subject <- 20
n.lat <- n.lon <- 10
n.site <- n.lat*n.lon
beta <- c(1,2,-1) # First 1 here is the intercept
midalpha <- c(1.15, 2.18) ; phi <- 0.6 ; sigma2 <- 0.7
true <- c(midalpha,beta,phi,sigma2)
Xi <- rnorm(n.subject,0,1) ; Xj <- rbinom(n.site,1,0.6)
VV <- matrix(NA, nrow = n.subject*n.site, ncol = 3)
for(i in 1:n.subject){ for(j in 1:n.site){
VV[(i-1)*n.site+j,] <- c(1,Xi[i],Xj[j])
}
}
location <- cbind(rep(seq(1,n.lat,length=n.lat),n.lat),rep(1:n.lon, each=n.lon))
sim.data <- sim.rord(n.subject, n.site, n.rep = 2, midalpha, beta, phi, sigma2, covar=VV, location)
# }
# NOT RUN {
options(digits=3)
result <- cle.rord(response=sim.data[[1]], covar=VV,
location = location ,radius = 4, n.sim = 100, output = TRUE, parallel=TRUE, n.core =2)
result$vec.par
# alpha2 alpha3 beta0 beta1 beta2 phi sigma^2
# 1.249 2.319 1.169 1.990 -1.000 0.668 0.678
result$vec.se
# alpha2 alpha3 beta0 beta1 beta2 phi sigma^2
# 0.0704 0.1201 0.1370 0.2272 0.0767 0.0346 0.1050
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab