# NOT RUN {
# fit concentration graph model with power law penalty
data(ability.cov)
N <- ability.cov$n.obs
mod1 <- searchGGM(S = ability.cov$cov, N = ability.cov$n.obs,
model = "concentration", penalty = "power", beta = 2*log(N))
mod1
plot(mod1)
# }
# NOT RUN {
# two disconnected blocks of correlated variables
library(MASS)
V <- 10
N <- 500
mu <- rep(0, V)
sigma <- matrix(0.9, V,V)
diag(sigma) <- 1
x <- cbind( MASS::mvrnorm(N, mu, sigma),
MASS::mvrnorm(N, mu, sigma) )
#
# fit a covariance graph with erdos penalty
mod2 <- searchGGM(x, model = "covariance",
penalty = "erdos")
plot(mod2, "adjacency")
# user defined penalty function
data(iris)
x <- iris[,-5]
N <- nrow(x)
V <- ncol(x)
ref <- matrix(0, V, V)
#
# penalize graphs different from a reference graph structure
myPenalty <- function(graph, beta)
{
beta * sum( abs(graph - ref) )
}
#
mod3 <- mixGGM(x, K = 3, model = "covariance",
penalty = myPenalty, beta = 2*V*log(N))
plot(mod3)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab