ssnet | R Documentation |
Fits generalized linear models with spike-and-slab priors whose (logit of)
probability of inclusion in the model is either assigned an intrinsic
autoregression as a prior to incorporate spatial information or is
unstructured. The model is fit using an EM algorithm where the E-step is
fit by glmnet()
and the M-step is fit using the
stan
function optimizing
(when IAR prior is employed).
ssnet(
x,
y,
family = c("gaussian", "binomial", "multinomial", "poisson", "cox"),
offset = NULL,
epsilon = 1e-04,
alpha = 0.95,
type.multinomial = "grouped",
maxit = 50,
init = rep(0, ncol(x)),
init.theta = 0.5,
ss = c(0.04, 0.5),
Warning = FALSE,
group = NULL,
iar.prior = FALSE,
adjmat = NULL,
iar.data = NULL,
tau.prior = "none",
tau.manual = NULL,
stan_manual = NULL,
opt.algorithm = "LBFGS",
p.bound = c(0.01, 0.99),
plot.pj = FALSE,
im.res = NULL,
verbose = FALSE,
print.iter = FALSE
)
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 |
alpha |
A scalar value between 0 and 1 determining the compromise
between the Ridge and Lasso models. When |
type.multinomial |
If |
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
|
init.theta |
A single value between 0 and 1 to initialize inclusion probabilities. When parameter groups is 2 or more, can be a vector of initial values for parameter inclusion probabilities. Default is 0.5 for all parameters. Currently, it is not supported to have parameter-specific initializations for inclusion probabilities. This may change in forthcoming updates. |
ss |
A vector of two positive scale values for the spike-and-slab mixture double-exponential prior, allowing for different scales for different predictors, leading to different amount of shrinkage. Smaller scale values give stronger shrinkage. While the smaller of the two input values will be treated as the spike scale, it is recommended to specify the spike scale as the first element of the vector. |
Warning |
Logical. If |
group |
A numeric vector, or an integer, or a list indicating the
groups of predictors. If |
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. |
iar.data |
A list of output from |
tau.prior |
One of |
tau.manual |
When |
stan_manual |
A |
opt.algorithm |
One of |
p.bound |
A vector defining the lower and upper boundaries for the
probabilities of inclusion in the model, respectively. Defaults to
|
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 |
verbose |
Logical. If |
print.iter |
Logical. When |
An object of class c("elnet" "glmnet" "bmlasso" "GLM")
.
If iar.data = NULL
, i.e. is left unspecified, then provided
that im.res
is specified, the function proximity_builder()
from the package sim2Dpredictr
builds the appropriate list of data
for optimization with stan
. Currently, im.res
can only handle
2D data. Future versions may allow images to be 3D. However, the function
will work given any appropriately specified neighborhood matrix, whatever
the original dimension.
While the type.multinomial option is included, it is only valid for traditional elastic net models. Thus far we have only extended the spike-and-slab models for grouped selection.
Banerjee:2015ssnet
\insertRefFriedman:2007ssnet
\insertRefFriedman:2010ssnet
\insertRefMorris:2017ssnet
\insertRefMorris:2019ssnet
\insertRefRockova+George:2018ssnet
\insertRefTang:2017ssnet
\insertRefTang:2018ssnet
library(sim2Dpredictr)
set.seed(223)
## 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.2)
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")
## stan model information
model_info <- mungeCARdata4stan(adjmat$nb.index,
table(adjmat$location.index))
## fit model
ex_model <- ssnet(x = tx, y = ty, alpha = 0.5,
iar.prior = TRUE, iar.data = model_info,
family = "gaussian")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.