fitNetwork {modnets} | R Documentation |
Fit cross-sectional and idiographic moderated network models
Description
The main function that ties everything together for both cross-sectional and idiographic (temporal) network models, moderated or otherwise.
Usage
fitNetwork(
data,
moderators = NULL,
type = "gaussian",
lags = NULL,
seed = NULL,
folds = 10,
gamma = 0.5,
which.lam = "min",
rule = "OR",
threshold = FALSE,
scale = FALSE,
std = TRUE,
center = TRUE,
covariates = NULL,
verbose = FALSE,
exogenous = TRUE,
mval = NULL,
residMat = "sigma",
medges = 1,
pcor = FALSE,
maxiter = 100,
getLL = TRUE,
saveMods = TRUE,
binarize = FALSE,
fitCoefs = FALSE,
detrend = FALSE,
beepno = NULL,
dayno = NULL,
...
)
Arguments
data |
|
moderators |
Numeric or character vector indicating which variables (if any) to use as moderators. |
type |
Primarily used to supply a variable selection object, such as
those created with |
lags |
Logical or numeric, to indicate whether to fit a SUR model or
not. Set to |
seed |
Only useful if |
folds |
Can be used to specify the number of folds in cross-validation
when |
gamma |
Only useful if |
which.lam |
Only useful if |
rule |
Only applies to GGMs (including between-subjects networks) when a
threshold is supplied. The |
threshold |
Determines whether to employ a p-value threshold on the
model. If |
scale |
Determines whether to standardize all variables or not. |
std |
Only applies to SUR networks. Logical. Provides input to the
|
center |
Determines whether to mean-center variables or not. |
covariates |
Either a numeric value or character string – this could also be a vector – to indicate which variables (if any) should be treated as covariates in the model. |
verbose |
Logical. Determines whether to return information about the progress of the model fitting – especially when variable selection is employed – as well as prints the amount of time it takes to fit the model to the console. |
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 |
mval |
Numeric value to set the moderator variable to when computing model coefficients. Useful to create conditional networks – i.e., those whose values are conditioned on specific values of the moderator. Excellent when the moderator is a categorical variable, or when it's desired to have model estimates at +/- 1 SD around the mean of the moderator. These values must be supplied explicitly. Can only specify a single value for a given model. |
residMat |
Character string indicating which type of residual covariance
matrix to compute for SUR models. Options include |
medges |
Only relevant when |
pcor |
Logical. Determines whether to operationalize the adjacency matrix as the partial correlation matrix of the data, or to use nodewise estimation. Only relevant for unmoderated networks. |
maxiter |
See argument of |
getLL |
Logical. Determines whether to return log-likelihood statistics
with model results. Recommended to keep |
saveMods |
Logical. Determines whether to save the |
binarize |
Logical. Determines whether to convert the output to a binary, unweighted network. Only relevant for GGMs. |
fitCoefs |
Determines whether to use the |
detrend |
Logical. Determines whether to remove linear trends from time series variables. Only applies to temporal networks. |
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 |
... |
Additional arguments. |
Details
For GGMs, nodewise estimation is utilized to fit models to each node, and
then aggregate results into the final network. For temporal networks that
represent data for a single subject, SUR estimation based on feasible
generalized least squares (FGLS) is used. Also incorporates the variable
selection functions to integrate model selection and estimation. Nodewise
estimation is used for all GGMs, and SUR estimation is used for temporal
networks. See systemfit
package for more information on the latter,
particularly via the systemfit::systemfit
function.
Value
A ggm or SUR network
Examples
fit1 <- fitNetwork(ggmDat)
fit2 <- fitNetwork(ggmDat, 'M', type = 'varSelect', criterion = 'BIC')
fit3 <- fitNetwork(gvarDat, 'M', lags = 1)