Description Usage Arguments Details Value Examples

Computes Bayesian information criterion for a given clustering of a data set.

1 | ```
cluster_BIC(data, centres)
``` |

`data` |
a matrix (n x m). Rows are observations, columns are predictors. |

`centres` |
matrix of cluster means (k x m), where k is the number of clusters. |

Bayesian information criterion (BIC) is calculated using the formula, BIC = -2 * log(L) + k*log(n). k is the number of free parameters, in this case is m*k + k - 1. n is the number of observations (rows of data). L is the liklihood for the given set of cluster centres.

BIC value

1 2 3 4 5 | ```
iris_mat <- as.matrix(iris[,1:4])
iris_centres2 <- tkmeans(iris_mat, 2 , 0.1, c(1,1,1,1), 1, 10, 0.001) # 2 clusters
iris_centres3 <- tkmeans(iris_mat, 3 , 0.1, c(1,1,1,1), 1, 10, 0.001) # 3 clusters
cluster_BIC(iris_mat, iris_centres2)
cluster_BIC(iris_mat, iris_centres3)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.