# NOT RUN {
set.seed(1)
# True parameters
true.par <- c(0.9, 2, 0.7, 0.6)
# Simulation of data from the GMCM model
data <- SimulateGMCMData(n = 1000, par = true.par)
uhat <- Uhat(data$u) # Ranked observed data
init.par <- c(0.5, 1, 0.5, 0.9) # Initial parameters
# Optimization with Nelder-Mead
nm.par <- fit.meta.GMCM(uhat, init.par = init.par, method = "NM")
# }
# NOT RUN {
# Comparison with other optimization methods
# Optimization with simulated annealing
sann.par <- fit.meta.GMCM(uhat, init.par = init.par, method = "SANN",
max.ite = 3000, temp = 1)
# Optimization with the Pseudo EM algorithm
pem.par <- fit.meta.GMCM(uhat, init.par = init.par, method = "PEM")
# The estimates agree nicely
rbind("True" = true.par, "Start" = init.par,
"NM" = nm.par, "SANN" = sann.par, "PEM" = pem.par)
# }
# NOT RUN {
# Get estimated cluster
Khat <- get.IDR(x = uhat, par = nm.par)$Khat
plot(uhat, col = Khat, main = "Clustering\nIDR < 0.05")
# }
Run the code above in your browser using DataLab