# NOT RUN {
## Load Swiss banknotes data
data(banknote)
x <- banknote[,-1]
## Perform otrimle clustering with default arguments
set.seed(1)
a <- otrimle(data=x, G=2, logicd=c(-Inf, -50, -10), ncores=1)
## Plot clustering
plot(a, data=x, what="clustering")
## Plot OTRIMLE criterion profiling
plot(a, what="criterion")
## Plot Improper log-likelihood profiling
plot(a, what="iloglik")
## P-P plot of the clusterwise empirical weighted squared Mahalanobis
## distances against the target distribution pchisq(, df=ncol(data))
plot(a, what="fit")
plot(a, what="fit", cluster=1)
## Perform the same otrimle as before with non-zero penalty
set.seed(1)
b <- otrimle(data=x, G=2, beta = 0.5, logicd=c(-Inf, -50, -10), ncores=1)
## Plot clustering
plot(b, data=x, what="clustering")
## Plot OTRIMLE criterion profiling
plot(b, what="criterion")
## Plot Improper log-likelihood profiling
plot(b, what="iloglik")
## P-P plot of the clusterwise empirical weighted squared Mahalanobis
## distances against the target distribution pchisq(, df=ncol(data))
plot(b, what="fit")
plot(b, 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
# }
Run the code above in your browser using DataLab