# NOT RUN {
# Generate simulated dataset.
n <- c(15, 15)
Theta <- new("RNGMIX.Theta", c = 2, pdf = rep("normal", 3))
a.theta1(Theta, 1) <- c(10, 20, 30)
a.theta1(Theta, 2) <- c(3, 4, 5)
a.theta2(Theta, 1) <- c(3, 2, 1)
a.theta2(Theta, 2) <- c(15, 10, 5)
simulated <- RNGMIX(Dataset.name = paste("simulated_", 1:4, sep = ""),
rseed = -1,
n = n,
Theta = a.Theta(Theta))
# Number of classes or nearest neighbours to be processed.
K <- c(as.integer(1 + log2(sum(n))), # Minimum v follows Sturges rule.
as.integer(10 * log10(sum(n)))) # Maximum v follows log10 rule.
# Estimate number of components, component weights and component parameters.
simulatedest <- REBMIX(model = "REBMVNORM",
Dataset = a.Dataset(simulated),
Preprocessing = "h",
cmax = 4,
Criterion = "BIC",
pdf = c("n", "n", "n"),
K = K[1]:K[2])
# Preprocess simulated dataset.
f <- demix(simulatedest, pos = 3, variables = c(1, 3))
f
# Plot finite mixture.
opar <- plot(simulatedest, pos = 3, nrow = 3, ncol = 1)
par(usr = opar[[2]]$usr, mfg = c(2, 1))
text(x = f[, 1], y = f[, 2], labels = format(f[, 3], digits = 3), cex = 0.8, pos = 1)
# }
Run the code above in your browser using DataLab