ridgePgen.kCV.groups: K-fold cross-validated loglikelihood of ridge precision...

View source: R/ridgePgenAndCo.R

ridgePgen.kCV.groupsR Documentation

K-fold cross-validated loglikelihood of ridge precision estimator with group-wise penalized variates.

Description

Function that calculates of the k-fold cross-validated negative (!) loglikelihood of the generalized ridge precision estimator, assuming that variates are grouped and penalized group-wise.

Usage

ridgePgen.kCV.groups(lambdaGrps, Y, fold=nrow(Y), 
                     groups, target, 
                     zeros=matrix(nrow=0, ncol=2), 
                     penalize.diag=TRUE, nInit=100, 
                     minSuccDiff=10^(-5)) 

Arguments

lambdaGrps

A numeric with penalty parameter values, one per group. Values should be specified in the same order as the first appearance of a group representative.

Y

Data matrix with samples as rows and variates as columns.

fold

A numeric or integer specifying the number of folds to apply in the cross-validation.

groups

Anumeric indicating to which group a variate belongs. Same values indicate same group.

target

A semi-positive definite target matrix towards which the estimate is shrunken.

zeros

A two-column matrix, with the first and second column containing the row- and column-index of zero precision elements.

penalize.diag

A logical indicating whether the diagonal should be penalized.

nInit

A numeric specifying the number of iterations.

minSuccDiff

A numeric: minimum successive difference (in terms of their penalized loglikelihood) between two succesive estimates to be achieved.

Details

The penalty matrix \boldsymbol{\Lambda} is parametrized as follows. The elements of \boldsymbol{\Lambda} are (\boldsymbol{\Lambda})_{j,j'} = \frac{1}{2} (\lambda_k + \lambda_{k'}) for j, j' = 1, \ldots, p if j and j' belong to groups k and k', respectively, where \lambda_k and \lambda_{k'} are the corresponding group-specific penalty parameters.

Value

The function returns a numeric containing the cross-validated negative loglikelihood.

Author(s)

W.N. van Wieringen.

References

van Wieringen, W.N. (2019), "The generalized ridge estimator of the inverse covariance matrix", Journal of Computational and Graphical Statistics, 28(4), 932-942.

See Also

ridgePgen

Examples

# set dimension and sample size
p <- 10
n <- 10

# penalty parameter matrix
lambda       <- matrix(1, p, p)
diag(lambda) <- 0.1

# generate precision matrix
Omega       <- matrix(0.4, p, p)
diag(Omega) <- 1
Sigma       <- solve(Omega)

# data 
Y <- mvtnorm::rmvnorm(n, mean=rep(0,p), sigma=Sigma)
S <- cov(Y)

# find optimal penalty parameters through cross-validation
lambdaOpt <- optPenaltyPgen.kCVauto.groups(Y, rep(10^(-10), 2), rep(10^(10), 2), 
                          groups=c(rep(0, p/2), rep(1, p/2)), 
                          target=matrix(0, p, p),
                          penalize.diag=FALSE, nInit=100, 
                          minSuccDiff=10^(-5)) 

# format the penalty matrix
lambdaOptVec <- c(rep(lambdaOpt[1], p/2), rep(lambdaOpt[2], p/2))
lambdaOptMat <- outer(lambdaOptVec, lambdaOptVec, "+")

# generalized ridge precision estimate
Phat <- ridgePgen(S, lambdaOptMat, matrix(0, p, p))

porridge documentation built on Oct. 16, 2023, 1:06 a.m.