View source: R/ridgePgenAndCo.R
| optPenaltyPgen.kCVauto.groups | R Documentation | 
Function that determines the optimal penalty parameters through maximization of the k-fold cross-validated log-likelihood score, assuming that variates are grouped and penalized group-wise.
optPenaltyPgen.kCVauto.groups(Y, lambdaMin, lambdaMax, 
                          lambdaInit=(lambdaMin + lambdaMax)/2,
                          fold=nrow(Y), groups, target, 
                          zeros=matrix(nrow=0, ncol=2), 
                          penalize.diag=TRUE, nInit=100, 
                          minSuccDiff=10^(-5)) 
Y | 
  Data   | 
lambdaMin | 
  A   | 
lambdaMax | 
  A   | 
lambdaInit | 
  A   | 
fold | 
  A   | 
groups | 
  A  | 
target | 
  A semi-positive definite target   | 
zeros | 
  A two-column   | 
penalize.diag | 
  A   | 
nInit | 
  A   | 
minSuccDiff | 
  A   | 
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.
The function returns a numeric containing the cross-validated optimal positive penalty parameters.
W.N. van Wieringen.
van Wieringen, W.N. (2019), "The generalized ridge estimator of the inverse covariance matrix", Journal of Computational and Graphical Statistics, 28(4), 932-942.
ridgePgen
# 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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.