if (!require(nlme))
stop()
data(Orthodont)
z1 <- rep(1, 4)
z2 <- c(8,10,12,14)
K <- list()
K[[1]] <- tcrossprod(z1,z1) ## Int
K[[2]] <- tcrossprod(z1,z2) + tcrossprod(z2,z1) ## Int:age
K[[3]] <- tcrossprod(z2,z2) ## age
names(K) <- c("Int", "Int:age", "age")
p <- 4
n <- 27
groups <- cbind(rep(1:p, each=n), rep((1:n), p))
if (FALSE) {
## Composite S
OrthodontCompositeS <- varComprob(distance ~ age*Sex, groups = groups,
data = Orthodont, varcov = K,
control=varComprob.control(method="compositeS", lower=c(0,-Inf,0)))
}
## Composite Tau
OrthodontCompositeTau <- varComprob(distance ~ age*Sex, groups = groups,
data = Orthodont, varcov = K,
control=varComprob.control(lower=c(0,-Inf,0)))
if (FALSE) {
summary(OrthodontCompositeTau)
## Classic S
OrthodontS <- varComprob(distance ~ age*Sex, groups = groups,
data = Orthodont, varcov = K,
control=varComprob.control(lower=c(0,-Inf,0),
method="S", psi="rocke"))
summary(OrthodontS)
}
if (FALSE) {
if (!require(WWGbook))
stop()
if (!require(nlme))
stop()
data(autism)
autism <- autism[complete.cases(autism),]
completi <- table(autism$childid)==5
completi <- names(completi[completi])
indici <- as.vector(unlist(sapply(completi,
function(x) which(autism$childid==x))))
ind <- rep(FALSE, nrow(autism))
ind[indici] <- TRUE
autism <- subset(autism, subset=ind) ## complete cases 41
attach(autism)
sicdegp.f <- factor(sicdegp)
age.f <- factor(age)
age.2 <- age - 2
sicdegp2 <- sicdegp
sicdegp2[sicdegp == 3] <- 0
sicdegp2[sicdegp == 2] <- 2
sicdegp2[sicdegp == 1] <- 1
sicdegp2.f <- factor(sicdegp2)
autism.updated <- subset(data.frame(autism,
sicdegp2.f, age.2), !is.na(vsae))
autism.grouped <- groupedData(vsae ~ age.2 | childid,
data=autism.updated, order.groups = FALSE)
p <- 5
n <- 41
z1 <- rep(1, p)
z2 <- c(0, 1, 3, 7, 11)
z3 <- z2^2
K <- list()
K[[1]] <- tcrossprod(z1,z1)
K[[2]] <- tcrossprod(z2,z2)
K[[3]] <- tcrossprod(z3,z3)
K[[4]] <- tcrossprod(z1,z2) + tcrossprod(z2,z1)
K[[5]] <- tcrossprod(z1,z3) + tcrossprod(z3,z1)
K[[6]] <- tcrossprod(z3,z2) + tcrossprod(z2,z3)
names(K) <- c("Int", "age", "age2", "Int:age", "Int:age2", "age:age2")
groups <- cbind(rep(1:p, each=n), rep((1:n), p))
## Composite Tau
AutismCompositeTau <- varComprob(vsae ~ age.2 + I(age.2^2)
+ sicdegp2.f + age.2:sicdegp2.f + I(age.2^2):sicdegp2.f,
groups = groups,
data = autism.grouped, varcov = K,
control=varComprob.control(
lower=c(0.01,0.01,0.01,-Inf,-Inf,-Inf)))
summary(AutismCompositeTau)
## Classic S
AutismS <- varComprob(vsae ~ age.2 + I(age.2^2)
+ sicdegp2.f + age.2:sicdegp2.f + I(age.2^2):sicdegp2.f,
groups = groups,
data = autism.grouped, varcov = K,
control=varComprob.control(
method="S", psi="rocke", cov.init="covOGK",
lower=c(0.01,0.01,0.01,-Inf,-Inf,-Inf)))
summary(AutismS)
}
Run the code above in your browser using DataLab