View source: R/validate_ssnet.R
validate_ssnet | R Documentation |
Fit a model using ssnet with training data and evaluate using test data.
validate_ssnet(
model = "ss",
alpha = 1,
classify = FALSE,
classify.rule = 0.5,
type.multinomial = "grouped",
s0 = 0.01,
s1 = 1,
x.train,
y.train,
x.test,
y.test,
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,
adjmat = NULL,
p.bound = c(0.01, 0.99),
tau.prior = "none",
tau.manual = NULL,
stan_manual = NULL,
nlambda = 100,
lambda.criteria = "lambda.min",
output_param_est = FALSE,
output_probs = FALSE,
print_check = FALSE
)
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 |
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.multinomial |
If |
s0, s1 |
A numeric value. When fitting a spike-and-slab model,
|
x.train, x.test |
Design matrices for training and test data, respectively. |
y.train, y.test |
Response/outcome vectors for training and testing, respectively. |
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 |
adjmat |
A data.frame or matrix containing a "sparse" representation of the neighbor relationships. The first column should contain a numerical index for a given location. Each index will be repeated in this column for every neighbor it has. The indices for the location's neighbors are then specified in the second column. Any additional columns are ignored. |
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 |
tau.manual |
When |
stan_manual |
A |
nlambda |
The number of |
lambda.criteria |
Determines the model selection criteria. When
|
output_param_est |
Logical. When |
output_probs |
Logical. When |
print_check |
Logical. When |
A list or a data frame. When output_param_est = FALSE
,
returns a data frame with a single row containing measures of model fitness.
Otherwise, returns a list with 2 elements. The first element,
model_fitness
, contains a data frame with a single row containing
measures of model fitness, and the second element, param_est
,
contains a data frame of parameter estimates.
xtr <- matrix(rnorm(100*5), nrow = 100, ncol = 5)
xte <- matrix(rnorm(100*5), nrow = 100, ncol = 5)
b <- rnorm(5)
## continuous
ytr <- xtr %*% b + rnorm(100)
yte <- xte %*% b + rnorm(100)
validate_ssnet(
model = "glmnet", family = "gaussian",
x.train = xtr, x.test = xte,
y.train = ytr, y.test = yte
)
validate_ssnet(
model = "ss", family = "gaussian",
x.train = xtr, x.test = xte,
y.train = ytr, y.test = yte
)
## binary
ybtr <- ifelse(ytr > 0, 1, 0)
ybte <- ifelse(yte > 0, 1, 0)
validate_ssnet(
model = "glmnet", family = "binomial",
x.train = xtr, x.test = xte,
y.train = ybtr, y.test = ybte,
classify = TRUE, s0 = 0.1
)
validate_ssnet(
model = "ss", family = "binomial",
x.train = xtr, x.test = xte,
y.train = ybtr, y.test = ybte,
classify = TRUE, s0 = 0.05, s1 = 1
)
## 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"
)
validate_ssnet(
model = "glmnet", family = "multinomial",
x.train = xtr, x.test = xte,
y.train = ymtr, y.test = ymte,
classify = TRUE, s0 = 0.1,
output_param_est = TRUE
)
validate_ssnet(
model = "ss", family = "multinomial",
x.train = xtr, x.test = xte,
y.train = ymtr, y.test = ymte,
classify = TRUE, s0 = 0.1, s1 = 1,
output_param_est = TRUE
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.