if (FALSE) {
## The model
m <- hlme(fixed = Y ~ Time, mixture = ~1, random = ~1, subject = "ID",
ng = 2, cor = BM(Time), data = data_hlme, B = c(0,20,30,-1,5,2,0.1))
## The random effects' variance matrix (the variance of the random intercept )
B <- createVarianceMatrix(m, which = "random")
## The variance of the Brownian motion at time c(1, 2, 3, 4)
W <- createVarianceMatrix(m, which = "cor", times1 = c(1, 2, 3, 4), times2 = c(1, 2, 3, 4))
## The variance of the measurement error at 4 visit times
S <- createVarianceMatrix(m, which = "error", nmes = 4)
## In model "m", the variance matrix of the outcome at times c(1, 2, 3, 4) is:
matrix(1, nrow = 4) %*% B %*% t(matrix(1, nrow = 4)) + W + S
}
Run the code above in your browser using DataLab