Skip to contents

Fits ridge regression on the RSS objective, enetRssWeights at alpha = 0: the penalty is \(\lambda \beta^T \beta\), and the default lambda path runs from 0.1 to 100. Searches over a shrinkage grid s as well, whose own ridge term \(s \beta^T \beta\) adds to it; model selection uses held-out summary statistics by default (see lassosumRssWeights).

Usage

ridgeRssWeights(
  stat,
  ldReference,
  s = c(0.2, 0.5, 0.9, 1),
  selection = c("heldOut", "ldQuadratic", "minFbeta"),
  fitRetention = c("none", "slim", "full"),
  methodArgs = PenalizedRssOptions()
)

Arguments

stat

A list of summary statistics: n (per-variant sample sizes) and the marginal effects as cor (standardized), z, b with seb, or b alone, taken as already standardized. The engine receives the standardized effects z / sqrt(n), with n the median of n.

ldReference

The LD reference the statistics' variants are matched to by stat$variantNames: a genotype panel (see readGenotypes), a GenotypeMixture or an LdMatrix. A genotype reference's LD is used through its standardized genotypes, never formed as a matrix.

s

Numeric vector of LD shrinkage parameters. Default: c(0.2, 0.5, 0.9, 1.0).

selection

How the returned candidate is chosen (see Details of lassosumRssWeights). "heldOut" (default) scores every candidate on held-out summary statistics and needs the reference's sample size, so an LdMatrix must record nSamples. "ldQuadratic" is lassosum's pseudovalidation and needs the fdrtool package. "minFbeta" picks the smallest objective, for debugging.

fitRetention

How much of the search is kept as the "fit" attribute of the returned weights. "none" (default) attaches nothing. "slim" keeps path, a table with one row per candidate (s, lambda) giving the solver's objective fbeta, loss, convergence flag conv and number of non-zero coefficients nparams, with selected marking the candidate returned. "full" also keeps beta, the candidates' coefficients (variants x candidates, in the rows' order).

methodArgs

Options forwarded to the solver, penalizedRss, built with PenalizedRssOptions. A bare list is refused: it cannot be checked against the engine, so a misspelled option would be silently ignored.

Value

A numeric vector of SNP coefficient weights. Unless fitRetention = "none", the search is attached as attribute "fit".

Details

Every fit is exact: the ridge has the closed form \(((1 - s) R + (s + \lambda) I)^{-1} z\), read from one eigendecomposition of the window's LD that every shrinkage level, lambda and held-out refit shares (for a genotype reference, from the singular value decomposition of its standardized genotypes, never forming the LD). The coordinate-descent settings thr and maxiter in methodArgs therefore do not apply.

Examples

data(eqtlRegionExample)
X <- eqtlRegionExample$X[, 1:30]
y <- eqtlRegionExample$yRes
ss <- lapply(
  seq_len(ncol(X)), function(j) coef(summary(lm(y ~ X[, j])))[2, 1:2])
stat <- list(
  b = vapply(ss, `[`, numeric(1), 1L),
  seb = vapply(ss, `[`, numeric(1), 2L),
  n = rep(nrow(X), ncol(X)),
  variantNames = colnames(X)
)
ridgeRssWeights(stat, LdMatrix(cor(X), nSamples = nrow(X)))
#>  [1] -7.119576e-04 -7.119576e-04  4.275742e-04 -8.463128e-05 -8.463128e-05
#>  [6] -2.952922e-04 -3.971762e-04  4.357152e-04 -2.313178e-04 -2.313178e-04
#> [11] -1.271435e-04 -4.141229e-04 -1.146519e-04 -2.051813e-04 -1.271435e-04
#> [16]  4.357152e-04 -3.836557e-04 -4.172550e-04  3.593387e-04 -4.172550e-04
#> [21] -4.172550e-04 -2.952922e-04 -4.172550e-04  4.151210e-05 -1.146519e-04
#> [26] -2.952922e-04 -8.248387e-04 -3.403799e-04  2.051328e-04  3.893767e-04
#> attr(,"penalized_rss_selection")
#>      mode     index   penalty     alpha         s    lambda 
#> "heldOut"      "80"   "lasso"       "0"       "1"     "100"