bootnet: Bootstrapped network estimation

View source: R/bootnet.R

bootnetR Documentation

Bootstrapped network estimation

Description

This function can be used to bootstrap network estimation methods so that the spread of parameter and centrality estimates can be assessed. Most important methods are type = 'nonparametric' for the non-parametric bootstrap and type = 'case' for the case-dropping bootstrap. See also Epskamp, Borsboom and Fried (2016) for more details.

Usage

bootnet(data, nBoots = 1000, default = c("none", "EBICglasso",
                 "ggmModSelect", "pcor", "IsingFit", "IsingSampler",
                 "huge", "adalasso", "mgm", "relimp", "cor", "TMFG",
                 "ggmModSelect", "LoGo", "SVAR_lavaan", "GGMncv"), type
                 = c("nonparametric", "parametric", "node", "person",
                 "jackknife", "case"), nCores = 1, statistics =
                 c("edge", "strength", "outStrength", "inStrength"),
                 model = c("detect", "GGM", "Ising", "graphicalVAR"),
                 fun, verbose = TRUE, labels, alpha = 1, caseMin =
                 0.05, caseMax = 0.75, caseN = 10, subNodes, subCases,
                 computeCentrality = TRUE, propBoot = 1, replacement =
                 TRUE, graph, sampleSize, intercepts, weighted, signed,
                 directed, includeDiagonal = FALSE, communities,
                 useCommunities, bridgeArgs = list(), library =
                 .libPaths(), memorysaver = TRUE, ...)

Arguments

data

A data frame or matrix containing the raw data. Must be numeric, integer or ordered factors.

nBoots

Number of bootstraps

default

A string indicating the method to use. See documentation at estimateNetwork.

type

The kind of bootstrap method to use.

nCores

Number of cores to use in computing results. Set to 1 to not use parallel computing.

statistics

Vector indicating which statistics to store. Options are:

"edge"

Edge-weight

"strength"

Degree or node-strength

"outStrength"

Out-degree or Out-strength

"inStrength"

In-degree or In-strength

"expectedInfluence"

Expected Influence

"outExpectedInfluence"

Outgoing expected influence

"inExpectedInfluence"

Incoming expected influence

"bridgeInDegree"

Bridge in-degree (see bridge)

"bridgeOutnDegree"

Bridge out-degree (see bridge)

"bridgeStrength"

Bridge-strength (see bridge)

"bridgeCloseness"

Bridge-closeness (see bridge)

"bridgeBetweenness"

Bridge-betweenness (see bridge)

"rspbc"

Randomized shortest paths betweenness centrality (see rspbc)

"hybrid"

Hybrid centrality (see hybrid)

"eigenvector"

Eigenvector centrality (see eigenvector)

Can contain "edge", "strength", "closeness", "betweenness", "length", "distance", "expectedInfluence", "inExpectedInfluence", "outExpectedInfluence". By default, length and distance are not stored.

model

The modeling framework to use. Automatically detects if data is binary or not.

fun

A custom estimation function, when no default set is used. This must be a function that takes the data as input (first argument) and returns either a weights matrix or a list containing the elements "graph" for the weights matrix, "intercepts" for the intercepts (optional) and "results" for the full estimation results (optional).

verbose

Logical. Should progress of the function be printed to the console?

labels

A character vector containing the node labels. If omitted the column names of the data are used.

alpha

The centrality tuning parameter as used in centrality.

subNodes

Range of nodes to sample in node-drop bootstrap

caseMin

Minimum proportion of cases to drop when type = "case".

caseMax

Maximum proportion of cases to drop when type = "case".

caseN

Number of sampling levels to test when type = "case".

subCases

Range of persons to sample in person-drop bootstrap

computeCentrality

Logical, should centrality be computed?

propBoot

Proportion of persons to sample in bootstraps. Set to lower than 1 for m out of n bootstrap

replacement

Logical, should replacement be used in bootstrap sampling?

graph

A given network structure to use in parametric bootstrap.

sampleSize

The samplesize to use in parametric bootstrap.

intercepts

Intercepts to use in parametric bootstrap.

weighted

Logical, should the analyzed network be weighted?

signed

Logical, should the analyzed network be signed?

directed

Logical, is the analyzed network directed? Usually does not have to be set and is detected automatically.

includeDiagonal

Logical, should diagonal elements (self-loops) be included in the bootstrap? Only used when directed = TRUE.

communities

Used for bridge centrality measures (see bridge).

useCommunities

Used for bridge centrality measures (see bridge).

library

Library location to be used in parallel computing.

memorysaver

Logical. If TRUE (recommended) then raw bootstrapped data and results are not stored in the output object. This saves a lot of memory. Set this only to TRUE if you need the raw results or bootstrap data.

bridgeArgs

List of arguments used in the 'bridge' function for computing bridge centrality

...

Additional arguments used in the estimator function.

Value

A bootnet object with the following elements:

sampleTable

A data frame containing all estimated values on the real sample.

bootTable

A data frame containing all estimated values on all bootstrapped samples.

sample

A bootnetResult object with plot and print method containing the estimated network of the real sample.

boots

A list of bootnetResult objects containing the raw bootstrap results.

Author(s)

Sacha Epskamp <mail@sachaepskamp.com>

References

Epskamp, S., Borsboom, D., & Fried, E. I. (2018). Estimating psychological networks and their accuracy: A tutorial paper. Behavior Research Methods, 50(1), 195-212.

See Also

estimateNetwork, differenceTest, corStability, plot.bootnet, summary.bootnet

Examples

# BFI Extraversion data from psychTools package:
library("psychTools")
data(bfi)
bfiSub <- bfi[,1:25]

# Estimate network:
Network <- estimateNetwork(bfiSub, default = "EBICglasso")

# Centrality indices:
library("qgraph")
centralityPlot(Network)


# Estimated network:
plot(Network, layout = 'spring') 

### Non-parametric bootstrap ###
# Bootstrap 1000 values, using 8 cores:
Results1 <- bootnet(Network, nBoots = 1000, nCores = 8)

# Plot bootstrapped edge CIs:
plot(Results1, labels = FALSE, order = "sample")

# Plot significant differences (alpha = 0.05) of edges:
plot(Results1, "edge", plot = "difference",onlyNonZero = TRUE,
     order = "sample") 

# Plot significant differences (alpha = 0.05) of node strength:
plot(Results1, "strength", plot = "difference")

# Test for difference in strength between node "A1" and "C2":
differenceTest(Results1,  "A1", "C2", "strength")

### Case-drop bootstrap ###
# Bootstrap 1000 values, using 8 cores:
Results2 <- bootnet(Network, nBoots = 1000, nCores = 8, 
              type = "case")

# Plot centrality stability:
plot(Results2)

# Compute CS-coefficients:
corStability(Results2)


bootnet documentation built on May 29, 2024, 8:38 a.m.