varSelect {modnets} | R Documentation |
Variable selection for moderated networks
Description
Perform variable selection via the LASSO, best subsets selection, forward selection, backward selection, or sequential replacement on unmoderated networks. Or, perform variable selection via the hierarchical LASSO for moderated networks. Can be used for both GGMs and SUR networks.
Usage
varSelect(
data,
m = NULL,
criterion = "AIC",
method = "glmnet",
lags = NULL,
exogenous = TRUE,
type = "g",
center = TRUE,
scale = FALSE,
gamma = 0.5,
nfolds = 10,
varSeed = NULL,
useSE = TRUE,
nlam = NULL,
covs = NULL,
verbose = TRUE,
beepno = NULL,
dayno = NULL
)
Arguments
data |
|
m |
Character vector or numeric vector indicating the moderator(s), if
any. Can also specify |
criterion |
The criterion for the variable selection procedure. Options
include: |
method |
Character string to indicate which method to use for variable
selection. Options include |
lags |
Numeric or logical. Can only be 0, 1 or |
exogenous |
Logical. Indicates whether moderator variables should be
treated as exogenous or not. If they are exogenous, they will not be
modeled as outcomes/nodes in the network. If the number of moderators
reaches |
type |
Determines whether to use gaussian models |
center |
Logical. Determines whether to mean-center the variables. |
scale |
Logical. Determines whether to standardize the variables. |
gamma |
Numeric value of the hyperparameter for the |
nfolds |
Only relevant if |
varSeed |
Numeric value providing a seed to be set at the beginning of the selection procedure. Recommended for reproducible results. |
useSE |
Logical. Only relevant if |
nlam |
if |
covs |
Numeric or character string indicating a variable to be used as a covariate. Currently not working properly. |
verbose |
Logical. Determines whether to provide output to the console about the status of the procedure. |
beepno |
Character string or numeric value to indicate which variable
(if any) encodes the survey number within a single day. Must be used in
conjunction with |
dayno |
Character string or numeric value to indicate which variable (if
any) encodes the survey number within a single day. Must be used in
conjunction with |
Details
The primary value of the output is to be used as input when fitting the
selected model with the fitNetwork
function. Specifically, the
output of varSelect
can be assigned to the type
argument
of fitNetwork
in order to fit the constrained models that were
selected across nodes.
For moderated networks, the only variable selection approach available is
through the glinternet
package, which implements the hierarchical
LASSO. The criterion for model selection dictates which function from the
package is used, where information criteria use the
glinternet::glinternet
function to
compute models, and cross-validation calls the
glinternet::glinternet.cv
function.
Value
List of all models, with the selected variables for each along with
model coefficients and the variable selection models themselves. Primarily
for use as input to the type
argument of the
fitNetwork
function.
See Also
resample, fitNetwork, bootNet,
mlGVAR, glinternet::glinternet,
glinternet::glinternet.cv,
glmnet::glmnet,
glmnet::cv.glmnet,
leaps::regsubsets
Examples
vars1 <- varSelect(ggmDat, criterion = 'BIC', method = 'subset')
fit1 <- fitNetwork(ggmDat, type = vars1)
vars2 <- varSelect(ggmDat, criterion = 'CV', method = 'glmnet')
fit2 <- fitNetwork(ggmDat, type = vars2, which.lam = 'min')
# Add a moderator
vars3 <- varSelect(ggmDat, m = 'M', criterion = 'EBIC', gamma = .5)
fit3 <- fitNetwork(ggmDat, moderators = 'M', type = vars3)