cv.lme1en: cv.lme1en

Description Usage Arguments Details Value Examples

View source: R/cv.lme1en.R

Description

Performing crossvalidation of lme1en (extension of inputs)

Usage

1
2
3
4
cv.lme1en(y, X, batch, rho = 0, lambda = 1, alpha = 0.5,
  beta = NULL, glmnetPenalty = TRUE, glmnetWarmup = TRUE,
  maxit = 10000, toler = 1e-05, verbose = FALSE, errorFun = NULL,
  Kfold = 10, CViter = 10, parallel = TRUE, seed = NULL)

Arguments

y

response vector. Must be normalized before input.

X

Design matrix belonging to fixed effects coefficients (beta). Must be normalized before input.

batch

factor with batch effect names (vector for each observations)

rho

proportion of variation explained by batch effect

lambda

numeric, penalty levels for fixed effects betas (component 1)

alpha

numeric, penalty levels for fixed effects betas (balancing LASSO/RIDGE erros)

beta

numeric, initial values of the beta coefficients (using glmnet or marginal estimates if not provided)

glmnetPenalty

boolean, whether to use the original peanalty (FALSE) or the glmnet penalty (TRUE)

glmnetWarmup

boolean, whether to use glmnet beta-estimates as warmup (if not marginals are used)

maxit

maximum number of iterations (i.e. forloops) in the coordinate decent algorithm

toler

tolerance level of beta changes for each iterations (similar to 'thresh' in glmnet)

verbose

boolean, show progress Default: FALSE

errorFun

function, The user can provide own error function to perform cross validation with (Default is MSE if function not provided). The function must be able to take equally long two vectors and return a number

Kfold

The train-test fold split: The training proportion becomes '(Kfold-1)/Kfold'

CViter

Number of iterations of the cross-validation

parallel

Boolean of whether parallelization in CV process should be applied (utilizing all CPUs)

seed

The user can set seed for reproducibility if wanted

Details

The function performs (possibly parallelized) K-fold cross validation for given alpha,lambda,rho The function assume that the response y and design matrix X are centralized (no intercept returned from function)

Value

matrix with error values (test and train) for each iterations

Examples

1
2
3
4
5
## Not run:  
dat = genData(seed=1)
CVerrors = cv.lme1en(y=dat$y,X=dat$X,batch=dat$batch, rho=0.3,verbose=TRUE,seed=1)

## End(Not run)

oyvble/lme1en documentation built on April 30, 2020, 2:41 p.m.