bootNet {modnets}R Documentation

Bootstrapping network estimation for moderated networks

Description

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.

Usage

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,
  ...
)

Arguments

data

Dataframe or matrix.

m

Numeric or character string. Indicates which variable should be treated as a moderator (if any).

nboots

Number of bootstrapped samples.

lags

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.

caseDrop

Logical. Determines whether to do a caseDrop bootstrap procedure or not.

rule

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.

ci

Numeric, between 0 and 1. The level of the confidence intervals estimated. Defaults at .95

caseMin

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,

caseMax

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,

caseN

Numeric. The number of samples to draw at each sample size tested when caseDrop = TRUE.

threshold

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.

fits

A list of all fitted models, if available. Not likely to be used.

type

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.

saveMods

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.

verbose

Logical. Determines whether a progress bar should be shown, as well as whether messages should be shown.

fitCoefs

Logical, refers to the argument in the fitNetwork function. Most likely this should always be FALSE.

size

Numeric. Size of sample to use for bootstrapping. Not recommended.

nCores

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.

cluster

Character string to indicate which type of parallelization function to use, if nCores > 1. Options are "mclapply" or "SOCK".

block

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.

maxiter

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.

directedDiag

logical

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 argument.

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 beepno argument.

...

Additional arguments.

Details

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.

Value

A bootNet object

Warning

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.

See Also

summary.bootNet, fitNetwork, varSelect, resample, plotBoot, plotNet, net, netInts

Examples


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)


[Package modnets version 0.9.0 Index]