Description Usage Arguments Value Examples
Model-based clustering with two clusters for two-dimensional data, where one of the dimensions is the hour of the day. Expectation maximization algorithm is implemented that takes into account that the hour of the day data are circular, i.e. 00:00 is the same as 24:00. The circularity is being handled by defining a truncated normal distribution.
1 |
x |
a matrix with the linear data in the first column and the circular data in the second one. |
diag |
a boolean indicating if the covariance matrix of the joint distribution is diagonal, i.e. the linear and the circular variables are independent. |
loglik Final log-likelihood estimate of the EM algorithm. parameters Parameters inferred by the algorithm: pro: Mixing proportion of each distribution. mean: Means of the two clusters. sigma: Covariance matrices of the two clusters. z: Responsibilities. classification: Classification of the datapoints to the clusters. iter: Number of iterations of the algorithm.
1 2 3 4 5 6 7 8 9 10 11 | require(mixtools)
x1 <- mixtools::rmvnorm(n= 250, mu= c(3.5,12), sigma= matrix(c(1,0,0,4),nrow=2,ncol=2))
x2 <- mixtools::rmvnorm(n= 350, mu= c(3,22), sigma= matrix(c(1,0,0,6),nrow=2,ncol=2))
x2[x2[,2]>24, 2] <- x2[x2[,2]>24, 2] - 24
x <- rbind(x1,x2,deparse.level=0)
x <- x[sample.int(nrow(x)),]
res <- circlust(x)
cat('mixing proportions:',res$parameters$pro,'\nmean of cluster 1:\n',res$parameters$mean[,1],
'\ncovariance matrix of cluster 1:\n',res$parameters$sigma[,,1],
'\nmean of cluster 2:\n',res$parameters$mean[,2],
'\ncovariance matrix of cluster 2:\n',res$parameters$sigma[,,2])
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.