cv_ssnet | R Documentation |
Perform k-fold cross validation for spike-and-slab elastic net models.
cv_ssnet(
model,
alpha = c(0.5, 1),
s0 = seq(0.01, 0.1, 0.01),
s1 = c(1, 2.5),
classify = FALSE,
classify.rule = 0.5,
nfolds = 10,
ncv = 1,
foldid = NULL,
fold.seed = NULL,
x,
y,
family,
offset = NULL,
epsilon = 1e-04,
maxit = 50,
init = NULL,
group = NULL,
Warning = FALSE,
verbose = FALSE,
opt.algorithm = "LBFGS",
iar.data = NULL,
iar.prior = FALSE,
p.bound = c(0.01, 0.99),
tau.prior = "none",
stan_manual = NULL,
lambda.criteria = "lambda.min",
output_param_est = FALSE,
type.multinomial = "grouped"
)
model |
Specify which model to fit. Options include
|
alpha |
A scalar value between 0 and 1 determining the compromise
between the Ridge and Lasso models. When |
s0, s1 |
A vector of user-selected possible values for the spike scale
and slab scale parameter, respectively. The default is
|
classify |
Logical. When |
classify.rule |
A value between 0 and 1. For a given predicted value
from a logistic regression, if the value is above |
nfolds |
Numeric value indicating the number of folds to create. |
ncv |
Numeric value indicating the number of times to perform cross validation. |
foldid |
An (optional) vector of values between 1 and |
fold.seed |
A scalar seed value for cross validation; ensures the
folds are the same upon re-running the function. Alternatively, use
|
x |
Design, or input, matrix, of dimension nobs x nvars; each row is
an observation vector. It is recommended that |
y |
Scalar response variable. Quantitative for
|
family |
Response type (see above). |
offset |
A vector of length |
epsilon |
A positive convergence tolerance; the iterations converge
when |
maxit |
An integer giving the maximal number of EM iterations. |
init |
A vector of initial values for all coefficients (not for
intercept). If not given, it will be internally produced. If
|
group |
A numeric vector, or an integer, or a list indicating the
groups of predictors. If |
Warning |
Logical. If |
verbose |
Logical. If |
opt.algorithm |
One of |
iar.data |
A list of output from |
iar.prior |
Logical. When |
p.bound |
A vector defining the lower and upper boundaries for the
probabilities of inclusion in the model, respectively. Defaults to
|
tau.prior |
One of |
stan_manual |
A |
lambda.criteria |
Determines the model selection criteria. When
|
output_param_est |
Logical. When |
type.multinomial |
If |
Either a data frame of model fitness measures or a list whose elements are data frames of model fitness measures and parameter estimates, respectively, depending on the value of output_param_ets.
xtr <- matrix(rnorm(100*5), nrow = 100, ncol = 5)
xte <- matrix(rnorm(100*5), nrow = 100, ncol = 5)
b <- rnorm(5)
## continuous outcome
ytr <- xtr %*% b + rnorm(100)
yte <- xte %*% b + rnorm(100)
## binary outcome
ybtr <- ifelse(ytr > 0, 1, 0)
ybte <- ifelse(yte > 0, 1, 0)
## multinomial outcome
ymtr <- dplyr::case_when(
ytr > 1 ~ "a",
ytr <= 1 & ytr > -1 ~ "b",
ytr <= -1 ~ "c"
)
ymte <- dplyr::case_when(
yte > 1 ~ "a",
yte <= 1 & yte > -1 ~ "b",
yte <= -1 ~ "c"
)
cv_ssnet(
model = "ss", family = "gaussian",
x = rbind(xtr, xte), y = c(ytr, yte),
s0 = c(0.01, 0.05, 0.10), s1 = c(1, 2.5),
nfolds = 3, ncv = 2
)
## Not run:
cv_ssnet(
model = "ss", family = "binomial",
x = rbind(xtr, xte), y = c(ybtr, ybte),
s0 = c(0.01, 0.05, 0.10), s1 = c(1, 2.5),
nfolds = 3, ncv = 2, classify = TRUE,
output_param_est = TRUE
)
cv_ssnet(
model = "ss", family = "multinomial",
x = rbind(xtr, xte), y = c(ymtr, ymte),
s0 = c(0.01, 0.05, 0.10), s1 = c(1, 2.5),
nfolds = 3, ncv = 2, classify = FALSE,
output_param_est = TRUE
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.