Skip to contents

Drop the conditions not in conditionsToKeep from each prior covariance matrix in U, optionally removing components whose weight is below wCutoff.

Usage

filterMixtureComponents(conditionsToKeep, U, w = NULL, wCutoff = 1e-04)

Arguments

conditionsToKeep

Character vector of condition names to retain.

U

Named list of prior covariance matrices (one per mixture component).

w

Optional numeric vector of mixture weights aligned to U.

wCutoff

Numeric. Drop components with weight below this. Default 1e-4.

Value

A list with the filtered U (and w when supplied).

Examples

conditionsToKeep <- c("cond1", "cond2")
cn <- c("cond1", "cond2", "cond3")
U <- list(shared = diag(3), corr = matrix(0.3, 3, 3) + diag(0.7, 3))
U <- lapply(U, function(m) {
  dimnames(m) <- list(cn, cn)
  m
})
filterMixtureComponents(conditionsToKeep = conditionsToKeep, U = U)
#> 2 components of matrices remained after filtering.
#> $U
#> $U$shared
#>       cond1 cond2
#> cond1     1     0
#> cond2     0     1
#> 
#> $U$corr
#>       cond1 cond2
#> cond1   1.0   0.3
#> cond2   0.3   1.0
#> 
#> 
#> $w
#> numeric(0)
#>