# NOT RUN {
# Create some (not at all high-dimensional) data on three classes
p <- 5 # Dimension
ns <- c(4, 6, 8) # Sample sizes (K = 3 classes)
Slist <- createS(ns, p = p)
str(Slist, max.level = 2) # The structure of Slist
#
# Estimate the precisions (using the complete penalty graph)
#
res1 <- ridgeP.fused(Slist, ns, lambda = c(1.3, 2.1))
print(res1)
# The same using the penalty matrix (the diagnal is ignored)
mylambda <- matrix(c(1.3, 2.1, 2.1,
2.1, 1.3, 2.1,
2.1, 2.1, 1.3), 3, 3, byrow = TRUE)
res2 <- ridgeP.fused(Slist, ns, lambda = mylambda)
stopifnot(all.equal(res1, res2))
#
# Estimate the precisions (using a non-complete penalty graph)
#
# Say we only want to shrink pairs (1,2) and (2,3) and not (1,3)
mylambda[1,3] <- mylambda[3,1] <- 0
print(mylambda)
res3 <- ridgeP.fused(Slist, ns, lambda = mylambda)
# which similar to, but not the same as res1 and res2.
#
# Using other custom target matrices
#
# Construct a custom target list
myTlist <- list(diag(p), matrix(1, p, p), matrix(0, p, p))
res4 <- ridgeP.fused(Slist, ns, Tlist = myTlist, lambda = c(1.3, 2.1))
print(res4)
# Alternative, see ?default.target.fused
myTlist2 <- default.target.fused(Slist, ns, type = "Null") # For the null target
res5 <- ridgeP.fused(Slist, ns, Tlist = myTlist2, lambda = c(1.3, 2.1))
print(res5)
# }
Run the code above in your browser using DataLab