merge_selective_inference: Merged version of the selective test

View source: R/merge_selective_inference.R

merge_selective_inferenceR Documentation

Merged version of the selective test

Description

Merged version of the selective test

Usage

merge_selective_inference(X, k1, k2, g, ndraws = 2000, cl_fun, cl)

Arguments

X

The data matrix of size on which the clustering is applied

k1

The first cluster of interest

k2

The second cluster of interest

g

The variables for which the test is applied

ndraws

The number of Monte-Carlo samples

cl_fun

The clustering function used to build clusters

cl

The labels of the data obtained thanks to the cl_fun function

Value

A list with the following elements

  • pval : The resulting p-values of the test.

  • adjacent : List of the adjacent clusters between k1 and k2

  • pval_adj : The corresponding adjacent p-values that are merged

Examples

X <- matrix(rnorm(200),ncol = 2)
hcl_fun <- function(x){
return(as.factor(cutree(hclust(dist(x), method = "ward.D2"), k=4)))}
cl <- hcl_fun(X)
plot(X, col=cl)
#Note that in practice the value of ndraws (the number of Monte-Carlo simulations must be higher)
test_var1 <- test_selective_inference(X, k1=1, k2=4, g=1, ndraws =100, cl_fun = hcl_fun, cl = cl)

benhvt/PCVI documentation built on Dec. 2, 2022, 10:47 p.m.