# Generate and plot univariate normal dataset.
n <- c(998, 263, 1086, 487)
Theta <- new("RNGMIX.Theta", c = 4, pdf = "normal")
a.theta1(Theta) <- c(688, 265, 30, 934)
a.theta2(Theta) <- c(72, 54, 34, 28)
normal <- RNGMIX(Dataset.name = "complex1",
rseed = -1,
n = n,
Theta = a.Theta(Theta))
normal
a.Dataset(normal, 1)[1:20,]
# Estimate number of components, component weights and component parameters.
normalest <- REBMIX(Dataset = a.Dataset(normal),
Preprocessing = "h",
cmax = 8,
Criterion = "BIC",
pdf = "n")
normalest
BIC(normalest)
logL(normalest)
# Plot finite mixture.
plot(normalest, nrow = 2, what = c("pdf", "marginal cdf"), npts = 1000)
# EM algorithm utilization
# Load iris data.
data(iris)
Dataset <- list(data.frame(iris[, c(1:4)]))
# Create EM.Control object.
EM <- new("EM.Control",
strategy = "exhaustive",
variant = "EM",
acceleration = "fixed",
tolerance = 1e-4,
acceleration.multiplier = 1.0,
maximum.iterations = 1000)
# Mixture parameter estimation using REBMIX and EM algorithm.
irisest <- REBMIX(model = "REBMVNORM",
Dataset = Dataset,
Preprocessing = "histogram",
cmax = 10,
Criterion = "BIC",
EMcontrol = EM)
irisest
# Print total number of EM iterations used in Ehxaustive strategy from summary.EM slot.
a.summary.EM(irisest, col.name = "total.iterations.nbr", pos = 1)
Run the code above in your browser using DataLab