Follows closely to the methods of bootstrapping found in the bootnet
package. An essential goal behind this function is to expand the methods in
bootnet
to encompass moderated networks.
bootNet(
data,
m = NULL,
nboots = 10,
lags = NULL,
caseDrop = FALSE,
rule = "OR",
ci = 0.95,
caseMin = 0.05,
caseMax = 0.75,
caseN = 10,
threshold = FALSE,
fits = NULL,
type = "g",
saveMods = TRUE,
verbose = TRUE,
fitCoefs = FALSE,
size = NULL,
nCores = 1,
cluster = "mclapply",
block = FALSE,
maxiter = 10,
directedDiag = FALSE,
beepno = NULL,
dayno = NULL,
...
)
Dataframe or matrix.
Numeric or character string. Indicates which variable should be treated as a moderator (if any).
Number of bootstrapped samples.
Numeric or logical, to indicate whether or not a temporal network
is being estimated. Maximum of 1 lag -- meaningful values are either 1 or
TRUE
.
Logical. Determines whether to do a caseDrop bootstrap procedure or not.
Only applies to GGMs (including between-subjects networks) when a
threshold is supplied. The "AND"
rule will only preserve edges when
both corresponding coefficients have p-values below the threshold, while
the "OR"
rule will preserve an edge so long as one of the two
coefficients have a p-value below the supplied threshold.
Numeric, between 0 and 1. The level of the confidence intervals estimated. Defaults at .95
Numeric. The minimum proportion of the sample that should be
taken when caseDrop = TRUE
. Provide a value between 0 and 1. The
value indicates the smallest proportion of the total sample size to test in
the case-dropping procedure,
Numeric. The maximum proportion of the sample that should be
taken when caseDrop = TRUE
. Provide a value between 0 and 1. The
value indicates the largest proportion of the total sample size to test in
the case-dropping procedure,
Numeric. The number of samples to draw at each sample size
tested when caseDrop = TRUE
.
Logical or numeric. If TRUE
, then a default value of
.05 will be set. Indicates whether a threshold should be placed on the
bootstrapped samples. A significant choice by the researcher. Only applies
when a variable selection procedure is applied, or whether a
resample
object is used as input.
A list of all fitted models, if available. Not likely to be used.
See type
argument in fitNetwork
function.
This is where a variable selection model can be provided. This will fit the
same selected model across all iterations of the bootstrapping procedure.
Logical. Determines whether or not to return all of the
fitted models -- that is, all the models fit to each bootstrapped sample.
Defaults to TRUE
, but if FALSE
then models will not be
returned which can save memory.
Logical. Determines whether a progress bar should be shown, as well as whether messages should be shown.
Logical, refers to the argument in the
fitNetwork
function. Most likely this should always be
FALSE
.
Numeric. Size of sample to use for bootstrapping. Not recommended.
If a logical or numeric value is provided, then the
bootstrapping procedure will be parallelized across multiple CPUs. If
numeric, this will specify the number of cores to use for the procedure. If
TRUE
, then the
parallel::detectCores
function of the
parallel
package will be run to maximize the number of cores
available. Defaults to 1, which does not run any parallelization functions.
Character string to indicate which type of parallelization
function to use, if nCores > 1
. Options are "mclapply"
or
"SOCK"
.
Logical or numeric. If specified, then this indicates that
lags != 0
or lags != NULL
. If numeric, then this indicates
that block bootstrapping will be used, and the value specifies the block
size. If TRUE
then an appropriate block size will be estimated
automatically.
The maximum number of iterations for the algorithm to go
through before stopping. In some circumstances, iterated versions of the
model based on subsamples of the data may not be possible to fit. In these
cases, maxiter
specifies the number of attempts that are made with
different versions of the sample before stopping the algorithm.
logical
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
argument.
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 beepno
argument.
Additional arguments.
A bootNet
object
Importantly, if output from the resample
function is used as
input for the bootNet
function, and the user wishes to use
the model selected by the resample
function as the comparison
to the bootstrapped results, you must add the fit0
argument to this
function. Use the fitted object in the resample
output as the
input for the undocumented fit0
argument for the
bootNet
function.
Can be used to perform bootstrapped network estimation, as well as perform a
case-drop bootstrap. Details on these two methods can be found in the help
page for the bootnet::bootnet
function.
The defining feature of bootNet
that differentiates it from the
resample
function when sampMethod = "bootstrap"
is that
the same model is fit at every iteration in bootNet
. The only
time that models may differ across iterations is if a threshold
is
specified. When threshold = FALSE
, then the saturated model is fit to
each bootstrapped sample. Alternatively, bootstrapping can be performed with
respect to a specific constrained model. In this case, the constrained model
(variable selection model; output of varSelect
or
resample
) can be supplied to the type
argument, and thus
this function provides a way to estimate the posterior distributions of the
nodes based on a constrained model.
In addition to expanding bootnet
to handle moderated networks, there
are also some additional features such as the capacity to perform the block
bootstrap for temporal networks via the block
argument. The block
bootstrap is highly recommended for resampling temporal networks.
Another feature of this function is that it can be used on outputs from the
resample
function. This can be used as a way to evaluate the
iterations of resample
beyond just using it for variable
selection.
summary.bootNet, fitNetwork, varSelect,
resample, plotBoot, plotNet, net,
netInts
# NOT RUN {
boot1 <- bootNet(ggmDat, 'M')
summary(boot1)
boot2 <- bootNet(gvarDat, 'M', lags = 1)
mod1 <- varSelect(gvarDat, 'M', lags = 1)
boot3 <- bootNet(gvarDat, 'M', lags = 1, type = mod1, caseDrop = TRUE)
summary(boot3)
# }
Run the code above in your browser using DataLab