shrinkr C API
Loading...
Searching...
No Matches
Public API

Functions available to users of shrinkr. More...

Functions

double C_OAS (const double *const sample_cov, double *const sample_cov_star, size_t n, size_t p)
 Oracle Approximating Shrinkage (OAS) covariance estimator.
 
void C_LWAnalytical (const double *const lam, double *const lam_star, size_t n, size_t p, double eps)
 Ledoit-Wolf Analytical (nonlinear) shrinkage of eigenvalues.
 
double C_LWLinear (const double *const data, const double *const sample_cov, double *const sample_cov_star, size_t n, size_t p)
 Ledoit-Wolf linear shrinkage estimator.
 
double C_DEALObjective (const double *const base_evals, const double *const surr_evals, const double *const z_vec, double gamma, double *start_value, size_t n, size_t p)
 Objective function of DEAL.
 
double C_DEAL (const double *const base_evals, const double *const surr_evals, const double *const z_vec, double gamma_min, double gamma_max, size_t n, size_t p)
 DEAL (Deterministic Equivalents for Adaptive LDA) shrinkage.
 

Detailed Description

Functions available to users of shrinkr.

Function Documentation

◆ C_DEAL()

double C_DEAL ( const double *const  base_evals,
const double *const  surr_evals,
const double *const  z_vec,
double  gamma_min,
double  gamma_max,
size_t  n,
size_t  p 
)

DEAL (Deterministic Equivalents for Adaptive LDA) shrinkage.

For more information check shrinkr.functional.deal.

Parameters
base_evalsArray of length p of eigenvalues for the objective. Which will be shrunk.
surr_evalsArray of length p of eigenvalues for the objective. Used to compute shrinkage paramters.
z_vecArray of length p of the vector of interest projected into the eigenvector space.
gamma_minMinimum value for the gamma bounded search.
gamma_maxMaximum value for the gamma bounded search.
nNumber of effective samples used to compute the sample covariance
pOne of the dimensions of the covariance matrix. Number of features.

◆ C_DEALObjective()

double C_DEALObjective ( const double *const  base_evals,
const double *const  surr_evals,
const double *const  z_vec,
double  gamma,
double *  start_value,
size_t  n,
size_t  p 
)

Objective function of DEAL.

For more information check shrinkr.functional.deal.

Parameters
base_evalsArray of length p of eigenvalues for the objective. Which will be shrunk.
surr_evalsArray of length p of eigenvalues for the objective. Used to compute shrinkage paramters.
z_vecArray of length p of the vector of interest projected into the eigenvector space.
gammaThe value of gamma to evaluate. During optimization only this value changes.
start_valueStarting value of delta for the fixed point iteration method used by for the objective.
nNumber of effective samples used to compute the sample covariance
pOne of the dimensions of the covariance matrix. Number of features.

◆ C_LWAnalytical()

void C_LWAnalytical ( const double *const  lam,
double *const  lam_star,
size_t  n,
size_t  p,
double  eps 
)

Ledoit-Wolf Analytical (nonlinear) shrinkage of eigenvalues.

Based on Ledoit and Wolf (2018), using the analytic formula that avoids numerical optimization. Handles the high-dimensional setting where p > n.

Parameters
lamArray of length p containing eigenvalues of the sample covariance matrix
lam_starArray buffer of length p for shrunk eigenvalues
sample_cov_starOutput buffer for the shurnk covariance (pxp) (C or F contiguous but matching sample_cov)
nNumber of samples used to compute the sample covariance
pNumber of variables. Length of lam and lam_star
epsEpsilon value for numerical stability

◆ C_LWLinear()

double C_LWLinear ( const double *const  data,
const double *const  sample_cov,
double *const  sample_cov_star,
size_t  n,
size_t  p 
)

Ledoit-Wolf linear shrinkage estimator.

Based on the Ledoit-Wolf Lemma. http://www.ledoit.net/ole1a.pdf

Parameters
dataData matrix (nxp) (C contiguous)
sample_covSample covariance matrix (pxp) (C or F contiguous)
sample_cov_starOutput buffer for the shurnk covariance (pxp) (C or F contiguous but matching sample_cov)
nNumber of samples used to compute the sample covariance
pOne of the dimensions of the covariance matrix

◆ C_OAS()

double C_OAS ( const double *const  sample_cov,
double *const  sample_cov_star,
size_t  n,
size_t  p 
)

Oracle Approximating Shrinkage (OAS) covariance estimator.

The formulation is based on https://arxiv.org/pdf/0907.4698.pdf.

Parameters
sample_covSample covariance matrix (pxp) (C or F contiguous)
sample_cov_starOutput buffer for the shurnk covariance (pxp) (C or F contiguous but matching sample_cov)
nNumber of samples used to compute the sample covariance
pOne of the dimensions of the matrix
Returns
The value of the linear shrinkage