bootnet: Bootstrapped network estimation

Description Usage Arguments Value Author(s) References See Also Examples

View source: R/bootnet.R

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
bootnet(data, nBoots = 1000, default = c("none", "EBICglasso", "pcor","IsingFit",
                  "IsingSampler", "huge","adalasso","mgm"), type =
                 c("nonparametric", "parametric", "node", "person",
                 "jackknife", "case"), nCores = 1, statistics = c("edge"
                 ,"strength","closeness","betweenness"), model = c("detect",
                 "GGM", "Ising"), fun, prepFun, prepArgs, estFun, estArgs,
                 graphFun, graphArgs, intFun, intArgs, verbose = TRUE,
                 construct = c("default", "function", "arguments"), labels, 
                 alpha = 1, caseMin = 0.05, caseMax = 0.75, caseN = 10,
                 subNodes = 2:(ncol(data) - 1), subCases = round((1 -
                 seq(caseMin, caseMax, length = caseN)) * nrow(data)),
                 computeCentrality = TRUE, propBoot = 1, replacement =
                 TRUE, graph, sampleSize, intercepts, weighted, signed,
                 directed, ...)

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. Can contain "edge", "strength", "closeness", "betweenness", "length" and "distance". 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).

prepFun

See documentation at estimateNetwork.

prepArgs

See documentation at estimateNetwork.

estFun

See documentation at estimateNetwork.

estArgs

See documentation at estimateNetwork.

graphFun

See documentation at estimateNetwork.

graphArgs

See documentation at estimateNetwork.

intFun

See documentation at estimateNetwork.

intArgs

See documentation at estimateNetwork.

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.

construct

How to construct the estimator? Set to "arguments" to use old functionality (not recommended).

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.

...

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. (2016). Estimating psychological networks and their accuracy: a tutorial paper. arXiv preprint, arXiv:1604.08462.

See Also

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# BFI Extraversion data from psych package:
library("psych")
data(bfi)
bfiSub <- bfi[,1:25]

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

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

## Not run: 
# 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(Results,  "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)

## End(Not run)

bootnet documentation built on May 29, 2017, 7:13 p.m.