Learn R Programming

rags2ridges (version 2.2.2)

pooledS: Compute the pooled covariance or precision matrix estimate

Description

Compute the pooled covariance or precision matrix estimate from a list of covariance matrices or precision matrices.

Usage

pooledS(Slist, ns, subset = rep(TRUE, length(ns)), mle = TRUE)
pooledP(Plist, ns, subset = rep(TRUE, length(ns)), mle = TRUE)

Arguments

Slist

A list of length \(G\) of numeric covariance matrices of the same size.

ns

A numeric vector for length \(G\) giving the sample sizes in the corresponding entries of Slist

mle

logical. If TRUE, the (biased) MLE is given. If FALSE, the biased corrected estimate is given. Default is TRUE.

subset

logical vector of the same length as Slist giving the classes to pool. Default is all classes.

Plist

A list of length \(G\) of invertible numeric precision matrices of the same size.

Value

pooledS returns the pooled covariance matrix, that is a numeric matrix with the same size as the elements of Slist. Similarly, pooledP returns the pooled precision matrix, i.e. a numeric matrix with the same size as the elements of Plist.

Details

When mle is FALSE the given covariance/precision matrices is assumed to have been computed using the denominator ns[i] - 1. Hence, the sum of all ns minus \(G\) is used a the denominator of the pooled estimate. Conversely, when mle is TRUE the total sum of the sample sizes ns is used as the denominator in the pooled estimate.

The function pooledP is equivalent to a wrapper for pooledS. That is, it inverts all the precision matrices in Plist, applies pooledS, and inverts the resulting matrix.

Examples

Run this code
# NOT RUN {
ns <- c(4, 6, 8)
Slist <- createS(ns, p = 6)

pooledS(Slist, ns)
pooledS(Slist, ns, mle = FALSE)

# Pool the first two classes only, leave out the remaning
pooledS(Slist, ns, subset = c(TRUE, TRUE, FALSE))
pooledS(Slist, ns, subset = ns > 5) # Pool studies with sample size > 5

# Pooled precision matrices
ns <- c(7, 8, 9)
Plist <- lapply(createS(ns, p = 6), solve)
pooledS(Plist, ns)
# }

Run the code above in your browser using DataLab