choose.theta: Heuristically chosen starting value of theta

Description Usage Arguments Details Value Note Author(s) Examples

View source: R/choose.theta.R

Description

This function uses a k-means algorithm to heuristically select suitable starting values for the general model.

Usage

1
choose.theta(u, m, no.scaling = FALSE, ...)

Arguments

u

A matrix of (estimates of) realizations from the GMCM.

m

The number of components to be fitted.

no.scaling

Logical. If TRUE, no scaling of the means and variance-covariance matrices is done.

...

Arguments passed to kmeans.

Details

The function selects the centers from the k-means algorithm as an initial estimate of the means. The proportional sizes of the clusters are selected as the initial values of the mixture proportions. The within cluster standard deviations are squared and used as the variance of the clusters within each dimension. The correlations between each dimension are taken to be zero.

Value

A list of parameters for the GMCM model on the form described in rtheta.

Note

The function uses the kmeans function from the stats-package.

Author(s)

Anders Ellern Bilgrau <anders.ellern.bilgrau@gmail.com>

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
set.seed(2)

# Simulating data
data1 <- SimulateGMCMData(n = 10000, m = 3, d = 2)
obs.data <- Uhat(data1$u)  # The ranked observed data

# Using choose.theta to get starting estimates
theta <- choose.theta(u = obs.data, m = 3)
print(theta)

# To illustrate theta, we can simulate from the model
data2 <- SimulateGMMData(n = 10000, theta = theta)

cols <- apply(get.prob(obs.data,theta),1,which.max)

# Plotting
par(mfrow = c(1,3))
plot(data1$z, main = "True latent GMM")
plot(Uhat(data1$u), col = cols,
     main = "Observed GMCM\nColoured by k-means clustering")
plot(data2$z, main = "initial GMM")

# Alteratively, theta can simply be plotted to illustrate the GMM density
par(mfrow = c(1,1))
plot(theta, add.ellipses = TRUE)
points(data2$z, pch = 16, cex = 0.4)

GMCM documentation built on Nov. 6, 2019, 1:08 a.m.