Description Usage Arguments Value References Examples
View source: R/test_indep_clust_subset.R
Implements the pseudo likelihood ratio test described in Section 3 of Gao et. al. (2019) "Are Clusterings of Multiple Data Views Independent?" for testing for dependence between clusterings of two data views. Fits Gaussian mixture models in each view, in the case where observations can be removed in one view but not the other (e.g. when view 1 data is available on 1st observation but view 2 data is not available on 2nd observation). Allows for fitting model-based clusterings on the full data views, and comparing these clusterings on subsets of the data views where observations are not removed in both views.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
x |
Multi-view data with two views; a list of two numeric vectors (in the case of univariate data) or matrices containing the two data views. In matrix format, rows correspond to observations and columns correspond to variables. |
model1 |
A character string indicating the model
to be fitted for Gaussian model-based clustering in view 1 using
the function |
model2 |
A character string indicating indicating the model
to be fitted for Gaussian model-based clustering in view 1 using
the function |
K1 |
An optional argument containing the number of clusters in View 1. If left out, then the number of clusters is chosen with BIC as described in Section 2.3.3 of "Are Clusterings of Multiple Data Views Independent?" |
K2 |
An optional argument containing the number of clusters in View 2. If left out, then the number of clusters is chosen with BIC as described in Section 2.3.3 of "Are Clusterings of Multiple Data Views Independent?" |
subset1 |
A numeric vector indicating the rows of the matrix containing the first data view that correspond to observations which have not been removed in the second data view. |
subset2 |
A numeric vector indicating the rows of the matrix containing the second data view that correspond to observations which have not been removed in the first data view. |
init1 |
An optional argument containing the model to be fitted in the
hierarchical clustering initialization in Gaussian model-based clustering
in view 1. The default is |
init2 |
An optional argument containing the model to be fitted in the
hierarchical clustering initialization in Gaussian model-based clustering
in view 2. The default is |
B |
An integer specifying the number of permutations to use for the permutation procedure. The default number is 200. |
step |
A numeric value containing the fixed step size to be used in the optimization algorithm for estimating Pi. The default step size is 0.001. See Appendix B in the Supplementary Materials of "Are Clusterings of Multiple Data Views Independent?" for details. |
maxiter |
A numeric value containing the maximum number of iterations to run in the optimization algorithm. The default maximum is 1000. |
A list containing the following output components:
K1 |
The number of clusters in view 1 |
K2 |
The number of clusters in view 2 |
Pi.est |
The estimated Pi matrix |
PLRstat |
The pseudo likelihood ratio test statistic |
pval |
The p-value |
modelfit1 |
The object of class ' |
modelfit2 |
The object of class ' |
Fraley C. and Raftery A. E. (2002) Model-based clustering, discriminant analysis and density estimation, Journal of the American Statistical Association, 97/458, pp. 611-631.
Gao, L.L., Bien, J., Witten, D. (2019) Are Clusterings of Multiple Data Views Independent? Biostatistics, <DOI:10.1093/biostatistics/kxz001>
Scrucca L., Fop M., Murphy T. B. and Raftery A. E. (2016) mclust 5: clustering, classification and density estimation using Gaussian finite mixture models, The R Journal, 8/1, pp. 205-233.
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 27 28 29 30 31 32 33 | set.seed(1)
n <- 50
sig <- 2
p <- 2
K <- 3
mu1 <- cbind(c(2, 0), c(0, 2), c(2, -2), c(-2, 0), c(0, -2), c(-2, 2))
mu2 <- cbind(c(-2, 0), c(0, -2), c(-2, 2), c(2, 0), c(0, 2), c(2, -2))
# Generates two-view data where the clusters are independent.
x1 <- list(matrix(sig* rnorm(n*p), n, p) + t(mu1)[sample(1:K, n, replace=TRUE), ],
matrix(sig * rnorm(n*p), n, p) + t(mu2)[sample(1:K, n, replace=TRUE), ])
# Generate two-view data where the clusters are identical.
n <- 71
cl <- sample(1:K, n, replace=TRUE)
x2 <- list(matrix(sig* rnorm(n*p), n, p) + t(mu1)[cl, ],
matrix(sig * rnorm(n*p), n, p) + t(mu2)[cl, ])
# Run the function on independent data views; we do not reject the null hypothesis.
# By default, not specifying K1 and K2 means the number of clusters
# to use in the test in each view is chosen via BIC.
# Covariance matrix model specified is shared sigma^2 I covariance matrix in view 1
# and shared diagonal covariance matrix in view 2.
# B specifies the number of permutations to do for the permutation test.
# Covariance matrix model specified for initialization
# is shared sigma^2 I covariance matrix in view 1
# Estimates Gaussian mixture model parameters on x1[[1]] and x1[[2]],
# and compares the estimated clusterings on the subsetted data
# x1[[1]][2:48, ] and x1[[1]][2:48, ].
indep1 <- test_indep_clust_subset(x1,model1="EII", model2="EEI",
subset1=2:48, subset2=2:48, init1="EII", B=51)
# The estimated cluster parameters in view 1
indep1$modelfit1$parameters
# The cluster assignments in view 2
indep1$modelfit2$classification
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.