# NOT RUN {
data(ais)
# Fit two sets of models
res1 <- MoE_clust(ais[,3:7], G=2, gating= ~ BMI, expert= ~ sex,
modelNames=c("VEE", "EVE", "VVE"), network.data=ais)
res2 <- MoE_clust(ais[,3:7], G=2, equalPro=TRUE, expert= ~ sex,
modelNames=c("VEE", "EVE", "VVE"), network.data=ais)
# Compare the best model from each set of results
(comp <- MoE_compare(res1, res2, optimal.only=TRUE))
# Produce a plot for the optimal model
plot(comp$optimal, what="gpairs")
# Summarise its classification table, component parameters, and gating/expert networks
summary(comp$optimal, classification=TRUE, parameters=TRUE, networks=TRUE)
data(CO2data)
CO2 <- CO2data$CO2
GNP <- CO2data$GNP
# Fit a range of models
m1 <- MoE_clust(CO2, G=1:3)
m2 <- MoE_clust(CO2, G=2:3, gating= ~ GNP)
m3 <- MoE_clust(CO2, G=1:3, expert= ~ GNP)
m4 <- MoE_clust(CO2, G=2:3, gating= ~ GNP, expert= ~ GNP)
m5 <- MoE_clust(CO2, G=2:3, equalPro=TRUE)
m6 <- MoE_clust(CO2, G=2:3, expert= ~ GNP, equalPro=TRUE)
# Extract the model with highest BIC
(comp <- MoE_compare(m1, m2, m3, m4, m5, m6, criterion="bic"))
# See if a better model can be found using greedy forward stepwise selection
# Conduct a stepwise search on the same data
(mod1 <- MoE_stepwise(CO2, CO2data[,"GNP", drop=FALSE]))
# Conduct another stepwise search considering models with a noise component
(mod2 <- MoE_stepwise(CO2, CO2data[,"GNP", drop=FALSE], noise=TRUE))
# Compare all sets of results to choose the optimal model
(best <- MoE_compare(mod1, mod2, comp, pick=1)$optimal)
# }
Run the code above in your browser using DataLab