cv.enetgt.grid: Peforms crossvalidation to select a combination of tuning...

View source: R/aenetgt.R

cv.enetgt.gridR Documentation

Peforms crossvalidation to select a combination of tuning parameters.

Description

Peforms crossvalidation to select a combination of tuning parameters.

Usage

cv.enetgt.grid(
  cv.fold.data,
  regime,
  Se,
  Sp,
  lambda.seq,
  theta.seq,
  weights,
  B.INIT,
  tol = 1e-04,
  E.approx = FALSE,
  verbose = FALSE,
  plot = FALSE
)

Arguments

cv.fold.data

Output from any of the functions get.xx.cv.fold.data, where xx is individual, masterpool, dorfman, or array.

regime

testing regime which must be equal to one of individual, masterpool, dorfman, and array.

Se

A vector of testing sensitivities, where the first element is the testing specificity for pools and the second entry is the test specificity for individual testing, if applicable.

Sp

A vector of testing specificities, where the first element is the testing specificity for pools and the second entry is the test specificity for individual testing, if applicable.

lambda.seq

Sequence of lambda values at which the weighted elastic net estimator will be computed.

theta.seq

Sequence of theta values at which the weighted elastic net estimator will be computed.

weights

Vector of weights to be used in weighting the l1 penalty. Default is weights=1, which causes equal weights to be used for each coefficient.

B.INIT

Array of values to be used to initialize the EM-algorithm at each of the tuning paramter combinations specified in lambda.seq and theta.seq.

tol

Convergence criterion.

E.approx

Logical. If TRUE then E-step done with EYapprox(). If FALSE, then E-step done with EYexact().

verbose

Logical. If TRUE then progress is reported after computation of the estimator at each tuning parameter pair.

plot

Logical. If TRUE then a plot is produced showing the mean of the crossvalidation estimates of the deviance over the null deviance.

Value

A list which includes the chosen values of the tuning parameters according to crossvalidation.

Examples

N <- 2000
data <- model1(N)
X <- data$X
Y.true <- data$Y
# subject individuals to individual testing
Se <- c(.94) # individual testing sensitivities
Sp <- c(.95) # individual testing specificities
assay.data <- individual.assay.gen(Y.true,Se,Sp,cj=1)
Z <- assay.data$Z
Y <- assay.data$Y
# compute the mle on the individual testing data:
mlegt.out <- mlegt(X,Y,Z,Se,Sp)
b.mle <- mlegt.out$b.mle
# compute adaptive elastic net estimator over a grid of tuning parameter values
n.lambda <- 8
n.theta <- 2
enetgt.grid.out <- enetgt.grid(X,Y,Z,Se,Sp,n.lambda,n.theta,weights = 1/abs(b.mle[-1]))
# make a choice of the tuning parameter using 3-fold crossvalidation:
cv.fold.data <- get.individual.cv.fold.data(X,Y,Z,K=5)
cv.enetgt.grid.out <- cv.enetgt.grid(cv.fold.data,"individual",
                                     Se,
                                     Sp,
                                     enetgt.grid.out$lambda.seq,
                                     enetgt.grid.out$theta.seq,
                                     weights=1/abs(b.mle[-1]),
                                     B.INIT=enetgt.grid.out$B.ENET)

b.aenet.cv <- enetgt.grid.out$B.ENET[cv.enetgt.grid.out$cv.ind[1],,cv.enetgt.grid.out$cv.ind[2]]
b.aenet.cv

gregorkb/aenetgt documentation built on Oct. 12, 2022, 11:51 a.m.