View source: R/compare_ssnet.R
compare_ssnet | R Documentation |
Fit glmnet
and/or ssnet
models
and output measures of model fit for each. Allows multiple scale values for
spike-and-slab models.
compare_ssnet(
models = c("glmnet", "ss", "ss_iar"),
alpha = c(0, 0.5, 1),
model_fit = "all",
variable_selection = FALSE,
classify = FALSE,
classify.rule = 0.5,
type_error = "kcv",
nfolds = 10,
ncv = 1,
foldid = NULL,
fold.seed = NULL,
s0 = seq(0.01, 0.1, 0.01),
s1 = 1,
B = NULL,
x,
y,
family = "gaussian",
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,
plot.pj = FALSE,
im.res = NULL,
nlambda = 100,
type.measure = c("default", "mse", "deviance", "class", "auc", "mae", "C"),
lambda.criteria = "lambda.min",
output_param_est = FALSE,
output_cv = FALSE
)
models |
A vector that determines which models to fit. Options include
|
alpha |
A scalar value between 0 and 1 determining the compromise
between the Ridge and Lasso models. When |
model_fit |
A vector containing measures of model fit to output.
Options include |
variable_selection |
Logical. When |
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 |
type_error |
Determines whether models are selected based on training
error ( |
nfolds |
number of folds - default is 10. Although |
ncv |
repeated number of 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
|
s0, s1 |
A vector of user-selected possible values for the spike scale
and slab scale parameter, respectively. The default is
|
B |
When |
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 |
plot.pj |
When |
im.res |
A 2-element vector where the first argument is the number of
"rows" and the second argument is the number of "columns" in each subject's
"image". Default is |
nlambda |
The number of |
type.measure |
loss to use for cross-validation. Currently five
options, not all available for all models. The default is
|
lambda.criteria |
Determines the model selection criteria. When
|
output_param_est |
Logical. When |
output_cv |
Logical. When |
criteria |
Specifies the criteria for model selection. Options are
|
When output_param_est = FALSE
returns a data frame of model
fitness summaries. Otherwise, returns a list whose first element is a
dataframe whose rows contain parameter estimates for each model fit, and
whose second element is a dataframe of model fitness summaries.
Models fit with 'glmnet' never select the penalty/tuning parameter
using the training error; however, when type_error = "training"
,
the measure used to compare 'glmnet' with the other models is based on
prediction error estimates from training error. That is, model selection
within 'glmnet' is still based on k-fold cross validation, even if
comparisons with other models is not.
library(sim2Dpredictr)
## generate data (no intercept)
set.seed(4799623)
## sample size
n <- 30
## image dims
nr <- 4
nc <- 4
## generate data
cn <- paste0("x", seq_len(nr * nc))
tb <- rbinom(nr * nc, 1, 0.05)
tx <- matrix(rnorm(n * nr * nc), nrow = n, ncol = nr * nc,
dimnames = list(seq_len(n), cn))
ty <- tx %*% tb + rnorm(n)
## build adjacency matrix
adjmat <- proximity_builder(im.res = c(nr, nc), type = "sparse")
## fit multiple models and compare
compare_ssnet(x = tx, y = ty, family = "gaussian",
alpha = c(0.5, 1), s0 = c(0.01, 0.05),
type_error = "kcv", nfolds = 3, im.res = c(4, 4),
model_fit = "all", variable_selection = TRUE,
B = tb)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.