# NOT RUN {
## Load Swiss banknotes data
data(banknote)
x <- banknote[,-1]
## Perform otrimle clustering on a small grid of logicd values
a <- otrimle(data = x, G = 2, logicd = c(-Inf, -50, -10), ncores = 1)
print(a)
## Plot clustering
plot(a, data = x, what = "clustering")
## Plot clustering on selected margins
plot(a, data = x, what = "clustering", margins = 4:6)
## Plot clustering on the first two principal components
z <- scale(x) %*% eigen(cor(x), symmetric = TRUE)$vectors
colnames(z) <- paste("PC", 1:ncol(z), sep = "")
plot(a, data = z, what = "clustering", margins = 1:2)
## Plot OTRIMLE criterion profiling
plot(a, what = "criterion")
## Plot Improper log-likelihood profiling
plot(a, what = "iloglik")
## Fit plot for all clusters
plot(a, what = "fit")
## Fit plot for cluster 1
plot(a, what = "fit", cluster = 1)
# }
# NOT RUN {
## Perform the same example using the finer default grid of logicd
## values using multiple cores
##
a <- otrimle(data = x, G = 2)
## Inspect the otrimle criterion-vs-logicd
plot(a, what = 'criterion')
## The minimum occurs at a$logicd=-9, and exploring a$optimization it
## cane be seen that the interval [-12.5, -4] brackets the optimal
## solution. We search with a finer grid located around the minimum
##
b <- otrimle(data = x, G = 2, logicd = seq(-12.5, -4, length.out = 25))
## Inspect the otrimle criterion-vs-logicd
plot(b, what = 'criterion')
## Check the difference between the two clusterings
table(A = a$cluster, B = b$cluster)
## Check differences in estimated parameters
##
colSums(abs(a$mean - b$mean)) ## L1 distance for mean vectors
apply({a$cov-b$cov}, 3, norm, type = "F") ## Frobenius distance for covariances
c(Noise=abs(a$npr-b$npr), abs(a$cpr-b$cpr)) ## Absolute difference for proportions
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab