Estimate linear models goodness of fit statistic
estimateStat.Rd
Estimate goodness of fit statistic of penalized linear regression models. Works with different goodness of fit statistic functions.
Arguments
- x
input matrix, of dimension nobs x nvars; each row is an observation vector. Can be in sparse matrix format (inherit from class
"sparseMatrix"
as in packageMatrix
)- y
response variable. Quantitative for
family="gaussian"
, orfamily="poisson"
(non-negative counts). Forfamily="binomial"
should be either a factor with two levels, or a two-column matrix of counts or proportions (the second column is treated as the target class; for a factor, the last level in alphabetical order is the target class). Forfamily="multinomial"
, can be anc>=2
level factor, or a matrix withnc
columns of counts or proportions. For either"binomial"
or"multinomial"
, ify
is presented as a vector, it will be coerced into a factor. Forfamily="cox"
, preferably aSurv
object from the survival package: see Details section for more information. Forfamily="mgaussian"
,y
is a matrix of quantitative responses.- u
offset vector as in
glmnet
."U"
experiment in mae.- s
user supplied lambda.
- method
currently only cross-validation is implemented.
- nfold
number of fold to use in cross-validation.
- statistic
function computing goodness of fit statistic. Should accept
y
,x
,offset
arguments and return a numeric vector of the same length. Seersq
,mse
for examples.- alpha
The elasticnet mixing parameter, with \(0\le\alpha\le 1\). The penalty is defined as $$(1-\alpha)/2||\beta||_2^2+\alpha||\beta||_1.$$
alpha=1
is the lasso penalty, andalpha=0
the ridge penalty.