optPenaltyPgen.kCVauto.banded: Automatic search for optimal penalty parameter (generalized...

View source: R/ridgePgenAndCo.R

optPenaltyPgen.kCVauto.bandedR Documentation

Automatic search for optimal penalty parameter (generalized ridge precision).

Description

Function that determines the optimal penalty parameters through maximization of the k-fold cross-validated log-likelihood score, with a penalization that encourages banded precisions.

Usage

optPenaltyPgen.kCVauto.banded(Y, lambdaMin, lambdaMax, 
                          lambdaInit=(lambdaMin + lambdaMax)/2,
                          fold=nrow(Y), target, 
                          zeros=matrix(nrow=0, ncol=2), 
                          penalize.diag=TRUE, nInit=100, 
                          minSuccDiff=10^(-5)) 

Arguments

Y

Data matrix with samples as rows and variates as columns.

lambdaMin

A numeric giving the minimum value for the penalty parameters. One value per group. Values should be specified in the same order as the first appearance of a group representative.

lambdaMax

A numeric giving the maximum value for the penalty parameters. One value per group. Values should be specified in the same order as the first appearance of a group representative.

lambdaInit

A numeric giving the initial (starting) value for the penalty parameters. One value per group. Values should be specified in the same order as the first appearance of a group representative.

fold

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

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'} = \lambda (| j - j'| + 1) for j, j' = 1, \ldots, p.

Value

The function returns a numeric containing the cross-validated optimal positive penalty parameters.

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.banded(Y, 10^(-10), 10^(10),
                          target=matrix(0, p, p),
                          penalize.diag=FALSE, nInit=100, 
                          minSuccDiff=10^(-5)) 

# format the penalty matrix
lambdaOptMat <- matrix(NA, p, p)
for (j1 in 1:p){
    for (j2 in 1:p){
        lambdaOptMat[j1, j2] <- lambdaOpt * (abs(j1-j2)+1)
    }
}

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

porridge documentation built on May 29, 2024, 1:37 a.m.