Computes the analytic mean-squared error (MSE), bias, and
variance for ridge regression estimators given different
values of the true beta
and sigma2
parameters.
mseRidge(lambda, XtX, beta, sigma2, penalize, ind = 1, XtXlamIinv = NULL)biasRidge(lambda, XtX, beta, penalize, ind = 1, XtXlamIinv = NULL)
varRidge(lambda, XtX, sigma2 = 1, penalize, ind = 1, XtXlamIinv = NULL)
penalty parameter value. For biasRidge
and varRidge
, this should be
a single value. For mseRidge
, either a single value of a list of values.
Cross product of design matrix. Not needed if XtXlamIinv
is provided.
True parameter values. Either a vector of length p
or a
p
x d
matrix.
Value of the variance parameter
Vector of penalty factors. See estRidge
for more information.
Numerical or logical vector indicating which elements of the bias vector and variance matrix should be returned. Defaults to the first element.
Optional explicit value of (XtX + diag(lambda*penalize))^(-1)
.
For mseRidge
, a list containing the variance, bias, and MSE. For biasRidge
and varRidge
, a matrix is returned.
The computations assume that all covariates are correctly included in the mean model and bias is due only to penalization. The bias is given by:
\(-(X'X + \Lambda)^{-1}\Lambda\beta\)
where \(\Lambda = diag(\lambda*penalize)\). The variance is given by:
\(\sigma^2(X'X + \Lambda)^{-1}X'X(X'X + \Lambda)^{-1}\)
If beta
is provided as a matrix, this will treat
each column of beta
as a different true parameter vector
and return a matrix of bias values (or a vector, if ind
has length 1).
Providing a pre-computed value of XtXlamIinv
can reduce the computational
cost in simulations. However, the user is responsible for assuring that the value
of lambda
provided matches the value used to compute XtXlamIinv
.