Title: | Bootstrap Methods for Various Network Estimation Routines |
---|---|
Description: | Bootstrap methods to assess accuracy and stability of estimated network structures and centrality indices <doi:10.3758/s13428-017-0862-1>. Allows for flexible specification of any undirected network estimation procedure in R, and offers default sets for various estimation routines. |
Authors: | Sacha Epskamp [aut, cre], Eiko I. Fried [ctb] |
Maintainer: | Sacha Epskamp <[email protected]> |
License: | GPL-2 |
Version: | 1.6 |
Built: | 2024-11-22 02:51:34 UTC |
Source: | https://github.com/sachaepskamp/bootnet |
Bootstrap standard errors on various network estimation routines, such as EBICglasso from the qgraph package and IsingFit from the IsingFit package. See bootnet
Sacha Epskamp
Maintainer: Sacha Epskamp <[email protected]>
This function will transform data into binary data (0,1). If the data is already binary, this function does nothing.
binarize(x, split = "median", na.rm = TRUE, removeNArows = TRUE, verbose = TRUE)
binarize(x, split = "median", na.rm = TRUE, removeNArows = TRUE, verbose = TRUE)
x |
A data frame or matrix |
split |
Either a function to split on (as character or as function) or a vector. e.g., |
na.rm |
The |
removeNArows |
Logical, should rows with |
verbose |
Output progress to the console? |
A binarized data frame
Sacha Epskamp <[email protected]>
This function takes bootstrap results and returns a inclusion probability network (edge weights indicate how often a certain edge was included in the model). Note that the plotting method automatically uses a black-white color scheme (as edges are not signed and always positive).
bootInclude(bootobject, verbose = TRUE)
bootInclude(bootobject, verbose = TRUE)
bootobject |
Nonparametric bootstrap results from |
verbose |
Logical, should progress be reported to the console? |
A bootnetResult
object with the following elements:
graph |
The weights matrix of the network |
intercepts |
The intercepts |
results |
The results of the estimation procedure |
labels |
A vector with node labels |
nNodes |
Number of nodes in the network |
nPerson |
Number of persons in the network |
input |
Input used, including the result of the default set used |
Sacha Epskamp <[email protected]>
## Not run: # BFI Extraversion data from psychTools package: library("psychTools") data(bfi) # Subset of data: bfiSub <- bfi[1:250,1:25] # Estimate ggmModSelect networks (not stepwise to increase speed): Network <- estimateNetwork(bfiSub], default = "ggmModSelect", corMethod = "cor", stepwise = FALSE) # Bootstrap 100 values, using 8 cores (100 to incease speed, preferably 1000+): boots <- bootnet(Network, nBoots = 100, nCores = 8) # Threshold network: Network_inclusion <- bootInclude(boots) # Plot: plot(Network_inclusion) ## End(Not run)
## Not run: # BFI Extraversion data from psychTools package: library("psychTools") data(bfi) # Subset of data: bfiSub <- bfi[1:250,1:25] # Estimate ggmModSelect networks (not stepwise to increase speed): Network <- estimateNetwork(bfiSub], default = "ggmModSelect", corMethod = "cor", stepwise = FALSE) # Bootstrap 100 values, using 8 cores (100 to incease speed, preferably 1000+): boots <- bootnet(Network, nBoots = 100, nCores = 8) # Threshold network: Network_inclusion <- bootInclude(boots) # Plot: plot(Network_inclusion) ## End(Not run)
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.
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, ...)
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, ...)
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 |
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:
Can contain |
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 |
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 |
subNodes |
Range of nodes to sample in node-drop bootstrap |
caseMin |
Minimum proportion of cases to drop when |
caseMax |
Maximum proportion of cases to drop when |
caseN |
Number of sampling levels to test when |
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 |
communities |
Used for bridge centrality measures (see |
useCommunities |
Used for bridge centrality measures (see |
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. |
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 |
boots |
A list of |
Sacha Epskamp <[email protected]>
Epskamp, S., Borsboom, D., & Fried, E. I. (2018). Estimating psychological networks and their accuracy: A tutorial paper. Behavior Research Methods, 50(1), 195-212.
estimateNetwork
, differenceTest
, corStability
, plot.bootnet
, summary.bootnet
# 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)
# 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)
This function takes the output of bootnet
and returns a network as if it had been estimated using estimateNetwork
, but with edges removed (set to zero) based on some significance level.
bootThreshold(bootobject, alpha = 0.05, verbose = TRUE, thresholdIntercepts = FALSE)
bootThreshold(bootobject, alpha = 0.05, verbose = TRUE, thresholdIntercepts = FALSE)
bootobject |
Nonparametric bootstrap results from |
alpha |
Significance level |
verbose |
Logical, should progress be reported to the console? |
thresholdIntercepts |
Logical, should intercepts also be thresholded? |
A bootnetResult
object with the following elements:
graph |
The weights matrix of the network |
intercepts |
The intercepts |
results |
The results of the estimation procedure |
labels |
A vector with node labels |
nNodes |
Number of nodes in the network |
nPerson |
Number of persons in the network |
input |
Input used, including the result of the default set used |
Sacha Epskamp <[email protected]>
## Not run: # BFI Extraversion data from psychTools package: library("psychTools") data(bfi) bfiSub <- bfi[,1:25] # Estimate unregularized network: Network <- estimateNetwork(bfiSub, default = "pcor", corMethod = "cor") # Bootstrap 1000 values, using 8 cores: boots <- bootnet(Network, nBoots = 1000, nCores = 8) # Threshold network: Network_thresholded <- bootThreshold(boots) # Plot: plot(Network_thresholded) ## End(Not run)
## Not run: # BFI Extraversion data from psychTools package: library("psychTools") data(bfi) bfiSub <- bfi[,1:25] # Estimate unregularized network: Network <- estimateNetwork(bfiSub, default = "pcor", corMethod = "cor") # Bootstrap 1000 values, using 8 cores: boots <- bootnet(Network, nBoots = 1000, nCores = 8) # Threshold network: Network_thresholded <- bootThreshold(boots) # Plot: plot(Network_thresholded) ## End(Not run)
This coefficient denotes the estimated maximum number of cases that can be dropped from the data to retain, with 95% probability, a correlation of at least 0.7 (default) between statistics based on the original network and statistics computed with less cases. This coefficient should not be below 0.25 and is preferably above 0.5. See also Epskamp, Borsboom and Fried (2016) for more details.
corStability(x, cor = 0.7, statistics = "all", verbose = TRUE)
corStability(x, cor = 0.7, statistics = "all", verbose = TRUE)
x |
Output of |
cor |
The correlation level tot est at. |
statistics |
The statistic(s) to test for. Can also be |
verbose |
Logical, should information on the progress be printed to the console? |
Sacha Epskamp <[email protected]>
Epskamp, S., Borsboom, D., & Fried, E. I. (2016). Estimating psychological networks and their accuracy: a tutorial paper. arXiv preprint, arXiv:1604.08462.
## Not run: # BFI Extraversion data from psychTools package: library("psychTools") data(bfi) bfiSub <- bfi[,1:25] # Estimate network: Network <- estimateNetwork(bfiSub, default = "EBICglasso") # Bootstrap 1000 values, using 8 cores: # Bootstrap 1000 values, using 8 cores: Results2 <- bootnet(Network, nBoots = 1000, nCores = 8, type = "case") # Compute CS-coefficients: corStability(Results2) ## End(Not run)
## Not run: # BFI Extraversion data from psychTools package: library("psychTools") data(bfi) bfiSub <- bfi[,1:25] # Estimate network: Network <- estimateNetwork(bfiSub, default = "EBICglasso") # Bootstrap 1000 values, using 8 cores: # Bootstrap 1000 values, using 8 cores: Results2 <- bootnet(Network, nBoots = 1000, nCores = 8, type = "case") # Compute CS-coefficients: corStability(Results2) ## End(Not run)
This function computes the bootstrapped difference test for edge-weights and centrality indices. A confidence interval is constructured on the difference of two values, and the test is deemed significant if zero is not in this confidence interval. See also Epskamp, Borsboom and Fried (2016) for more details.
differenceTest(bootobject, x, y, measure = c("strength", "closeness", "betweenness"), alpha = 0.05, x2, y2, verbose = TRUE)
differenceTest(bootobject, x, y, measure = c("strength", "closeness", "betweenness"), alpha = 0.05, x2, y2, verbose = TRUE)
bootobject |
Output of |
x |
A character string indicating the ID of a node or an edge, or a number indiacting the node or edge. For an edge, can be e.g., |
y |
A character string indicating the ID of a node or an edge, or a number indiacting the node or edge. For an edge, can be e.g., |
measure |
Measure to test. Can be |
alpha |
Signifiance level to test at. Note that the actual signifiance level is influenced by the number of bootstrap samples, and is returned in a message. |
x2 |
Second node in an edge. optional. |
y2 |
Second node in an edge. optional. |
verbose |
Logical, should the message indiacting actual signifiance level be printed? |
Sacha Epskamp <[email protected]>
Epskamp, S., Borsboom, D., & Fried, E. I. (2016). Estimating psychological networks and their accuracy: a tutorial paper. arXiv preprint, arXiv:1604.08462.
## Not run: # BFI Extraversion data from psychTools package: library("psychTools") data(bfi) bfiSub <- bfi[,1:25] # Estimate network: Network <- estimateNetwork(bfiSub, default = "EBICglasso") # Bootstrap 1000 values, using 8 cores: Results1 <- bootnet(Network, nBoots = 1000, nCores = 8) # Test for difference in strength between node "A1" and "C2": differenceTest(Results, "A1", "C2", "strength") # Test for difference between edge N1--N2 and N3--N4: differenceTest(Results, "N1--N2", "N3--N4", "edge") # Alternative: differenceTest(Results, x = "N1", x2 = "N2", y = "N3", y2 = "N4", measure = "edge") ## End(Not run)
## Not run: # BFI Extraversion data from psychTools package: library("psychTools") data(bfi) bfiSub <- bfi[,1:25] # Estimate network: Network <- estimateNetwork(bfiSub, default = "EBICglasso") # Bootstrap 1000 values, using 8 cores: Results1 <- bootnet(Network, nBoots = 1000, nCores = 8) # Test for difference in strength between node "A1" and "C2": differenceTest(Results, "A1", "C2", "strength") # Test for difference between edge N1--N2 and N3--N4: differenceTest(Results, "N1--N2", "N3--N4", "edge") # Alternative: differenceTest(Results, x = "N1", x2 = "N2", y = "N3", y2 = "N4", measure = "edge") ## End(Not run)
This function allows for flexible estimation of a network structure using various R packages and model frameworks. This is typically done by using one of the default sets. See details for manual specification. See also Epskamp, Borsboom and Fried (2016) for more details. IMPORTANT: THE ESTIMATOR FUNCTIONS (e.g., fun = bootnet_pcor
) ARE NOT INTENDED TO BE USED MANUALY (see details).
estimateNetwork(data, default = c("none", "EBICglasso", "pcor", "IsingFit", "IsingSampler", "huge", "adalasso", "mgm", "relimp", "cor", "TMFG", "ggmModSelect", "LoGo", "graphicalVAR", "piecewiseIsing", "SVAR_lavaan", "GGMncv"), fun, labels, verbose = TRUE, .dots = list(), weighted = TRUE, signed = TRUE, directed, datatype, checkNumeric = FALSE, ..., .input, memorysaver = FALSE) bootnet_EBICglasso(data, tuning = 0.5, corMethod = c("cor", "cov", "cor_auto", "npn", "spearman"), missing = c("pairwise", "listwise", "fiml", "stop"), sampleSize = c("pairwise_average", "maximum", "minimum", "pairwise_maximum", "pairwise_minimum", "pairwise_average_v1.5", "pairwise_maximum_v1.5", "pairwise_minimum_v1.5"), verbose = TRUE, corArgs = list(), refit = FALSE, principalDirection = FALSE, lambda.min.ratio = 0.01, nlambda = 100, threshold = FALSE, unlock = FALSE, nonPositiveDefinite = c("stop", "continue"), transform = c("none", "rank", "quantile"), ...) bootnet_pcor(data, corMethod = c("cor", "cov", "cor_auto", "npn", "spearman"), missing = c("pairwise", "listwise", "fiml", "stop"), sampleSize = c("pairwise_average", "maximum", "minimum", "pairwise_maximum", "pairwise_minimum", "pairwise_average_v1.5", "pairwise_maximum_v1.5", "pairwise_minimum_v1.5"), verbose = TRUE, corArgs = list(), threshold = 0, alpha = 0.05, adjacency, principalDirection = FALSE, unlock = FALSE, nonPositiveDefinite = c("stop", "continue"), transform = c("none", "rank", "quantile")) bootnet_cor(data, corMethod = c("cor", "cov", "cor_auto", "npn", "spearman"), missing = c("pairwise", "listwise", "fiml", "stop"), sampleSize = c("pairwise_average", "maximum", "minimum", "pairwise_maximum", "pairwise_minimum", "pairwise_average_v1.5", "pairwise_maximum_v1.5", "pairwise_minimum_v1.5"), verbose = TRUE, corArgs = list(), threshold = 0, alpha = 0.05, principalDirection = FALSE, unlock = FALSE, nonPositiveDefinite = c("stop", "continue"), transform = c("none", "rank", "quantile")) bootnet_IsingFit(data, tuning = 0.25, missing = c("listwise", "stop"), verbose = TRUE, rule = c("AND", "OR"), split = "median", principalDirection = FALSE, min_sum = -Inf, unlock = FALSE) bootnet_IsingSampler(data, missing = c("listwise", "stop"), verbose = TRUE, split = "median", method = c("uni", "ll", "pl", "bi"), principalDirection = FALSE, unlock = FALSE, threshold = FALSE, alpha = 0.01, min_sum = -Inf, rule = c("AND", "OR")) bootnet_adalasso(data, missing = c("listwise", "stop"), verbose = TRUE, nFolds = 10, principalDirection = FALSE, unlock = FALSE, transform = c("none", "rank", "quantile"), ...) bootnet_huge(data, tuning = 0.5, missing = c("listwise", "stop"), verbose = TRUE, npn = TRUE, criterion = c("ebic", "ric", "stars"), principalDirection = FALSE, lambda.min.ratio = 0.01, nlambda = 100, unlock = FALSE, transform = c("none", "rank", "quantile"), ...) bootnet_mgm(data, type, level, tuning = 0.25, missing = c("listwise", "stop"), verbose = TRUE, criterion = c("EBIC", "CV"), nFolds = 10, order = 2, rule = c("AND", "OR"), binarySign, unlock = FALSE, transform = c("none", "rank", "quantile"), ...) bootnet_relimp(data, normalized = TRUE, type = "lmg", structureDefault = c("none", "custom", "EBICglasso", "pcor", "IsingFit", "IsingSampler", "huge", "adalasso", "mgm", "cor", "TMFG", "ggmModSelect", "LoGo"), missing = c("listwise", "stop"), ..., verbose = TRUE, threshold = 0, unlock = FALSE, transform = c("none", "rank", "quantile")) bootnet_TMFG(data, graphType = c("cor", "pcor"), corMethod = c("cor", "cov", "cor", "npn", "cor_auto"), missing = c("pairwise", "listwise", "fiml", "stop"), verbose = TRUE, corArgs = list(), principalDirection = FALSE, unlock = FALSE, transform = c("none", "rank", "quantile"), ...) bootnet_LoGo(data, corMethod = c("cor", "cov", "cor", "npn", "cor_auto"), missing = c("pairwise", "listwise", "fiml", "stop"), verbose = TRUE, corArgs = list(), principalDirection = FALSE, unlock = FALSE, transform = c("none", "rank", "quantile"), ...) bootnet_graphicalVAR(data, tuning = 0.5, verbose = TRUE, principalDirection = FALSE, missing = c("listwise", "stop"), unlock = FALSE, transform = c("none", "rank", "quantile"), ...) bootnet_ggmModSelect(data, tuning = 0, corMethod = c("cor", "cov", "cor_auto", "npn", "spearman"), missing = c("pairwise", "listwise", "fiml", "stop"), sampleSize = c("pairwise_average", "maximum", "minimum", "pairwise_maximum", "pairwise_minimum", "pairwise_average_v1.5", "pairwise_maximum_v1.5", "pairwise_minimum_v1.5"), verbose = TRUE, corArgs = list(), principalDirection = FALSE, start = c("glasso", "empty", "full"), stepwise = TRUE, nCores = 1, unlock = FALSE, nonPositiveDefinite = c("stop", "continue"), transform = c("none", "rank", "quantile"), ...) bootnet_piecewiseIsing(data, cutoff, missing = c("listwise", "stop"), verbose = TRUE, IsingDefault = c("IsingSampler", "IsingFit", "custom"), zeroThreshold = 1, minimalN = ncol(data) + 1, unlock = FALSE, ...) bootnet_SVAR_lavaan(data, verbose = TRUE, principalDirection = FALSE, missing = c("listwise", "stop"), criterion = "bic", eqThreshold = 1e-04, tempWhitelist, tempBlacklist, contWhitelist, contBlacklist, minimalModInd = 10, unlock = FALSE, transform = c("none", "rank", "quantile"), ...) bootnet_GGMncv(data, penalty = c("atan", "selo", "exp", "log", "sica", "scad", "mcp", "lasso"), corMethod = c("cor", "cov", "cor_auto", "npn", "spearman"), missing = c("pairwise", "listwise", "fiml", "stop"), sampleSize = c("pairwise_average", "maximum", "minimum", "pairwise_maximum", "pairwise_minimum", "pairwise_average_v1.5", "pairwise_maximum_v1.5", "pairwise_minimum_v1.5"), verbose = TRUE, corArgs = list(), principalDirection = FALSE, unlock = FALSE, nonPositiveDefinite = c("stop", "continue"), transform = c("none", "rank", "quantile"), ...)
estimateNetwork(data, default = c("none", "EBICglasso", "pcor", "IsingFit", "IsingSampler", "huge", "adalasso", "mgm", "relimp", "cor", "TMFG", "ggmModSelect", "LoGo", "graphicalVAR", "piecewiseIsing", "SVAR_lavaan", "GGMncv"), fun, labels, verbose = TRUE, .dots = list(), weighted = TRUE, signed = TRUE, directed, datatype, checkNumeric = FALSE, ..., .input, memorysaver = FALSE) bootnet_EBICglasso(data, tuning = 0.5, corMethod = c("cor", "cov", "cor_auto", "npn", "spearman"), missing = c("pairwise", "listwise", "fiml", "stop"), sampleSize = c("pairwise_average", "maximum", "minimum", "pairwise_maximum", "pairwise_minimum", "pairwise_average_v1.5", "pairwise_maximum_v1.5", "pairwise_minimum_v1.5"), verbose = TRUE, corArgs = list(), refit = FALSE, principalDirection = FALSE, lambda.min.ratio = 0.01, nlambda = 100, threshold = FALSE, unlock = FALSE, nonPositiveDefinite = c("stop", "continue"), transform = c("none", "rank", "quantile"), ...) bootnet_pcor(data, corMethod = c("cor", "cov", "cor_auto", "npn", "spearman"), missing = c("pairwise", "listwise", "fiml", "stop"), sampleSize = c("pairwise_average", "maximum", "minimum", "pairwise_maximum", "pairwise_minimum", "pairwise_average_v1.5", "pairwise_maximum_v1.5", "pairwise_minimum_v1.5"), verbose = TRUE, corArgs = list(), threshold = 0, alpha = 0.05, adjacency, principalDirection = FALSE, unlock = FALSE, nonPositiveDefinite = c("stop", "continue"), transform = c("none", "rank", "quantile")) bootnet_cor(data, corMethod = c("cor", "cov", "cor_auto", "npn", "spearman"), missing = c("pairwise", "listwise", "fiml", "stop"), sampleSize = c("pairwise_average", "maximum", "minimum", "pairwise_maximum", "pairwise_minimum", "pairwise_average_v1.5", "pairwise_maximum_v1.5", "pairwise_minimum_v1.5"), verbose = TRUE, corArgs = list(), threshold = 0, alpha = 0.05, principalDirection = FALSE, unlock = FALSE, nonPositiveDefinite = c("stop", "continue"), transform = c("none", "rank", "quantile")) bootnet_IsingFit(data, tuning = 0.25, missing = c("listwise", "stop"), verbose = TRUE, rule = c("AND", "OR"), split = "median", principalDirection = FALSE, min_sum = -Inf, unlock = FALSE) bootnet_IsingSampler(data, missing = c("listwise", "stop"), verbose = TRUE, split = "median", method = c("uni", "ll", "pl", "bi"), principalDirection = FALSE, unlock = FALSE, threshold = FALSE, alpha = 0.01, min_sum = -Inf, rule = c("AND", "OR")) bootnet_adalasso(data, missing = c("listwise", "stop"), verbose = TRUE, nFolds = 10, principalDirection = FALSE, unlock = FALSE, transform = c("none", "rank", "quantile"), ...) bootnet_huge(data, tuning = 0.5, missing = c("listwise", "stop"), verbose = TRUE, npn = TRUE, criterion = c("ebic", "ric", "stars"), principalDirection = FALSE, lambda.min.ratio = 0.01, nlambda = 100, unlock = FALSE, transform = c("none", "rank", "quantile"), ...) bootnet_mgm(data, type, level, tuning = 0.25, missing = c("listwise", "stop"), verbose = TRUE, criterion = c("EBIC", "CV"), nFolds = 10, order = 2, rule = c("AND", "OR"), binarySign, unlock = FALSE, transform = c("none", "rank", "quantile"), ...) bootnet_relimp(data, normalized = TRUE, type = "lmg", structureDefault = c("none", "custom", "EBICglasso", "pcor", "IsingFit", "IsingSampler", "huge", "adalasso", "mgm", "cor", "TMFG", "ggmModSelect", "LoGo"), missing = c("listwise", "stop"), ..., verbose = TRUE, threshold = 0, unlock = FALSE, transform = c("none", "rank", "quantile")) bootnet_TMFG(data, graphType = c("cor", "pcor"), corMethod = c("cor", "cov", "cor", "npn", "cor_auto"), missing = c("pairwise", "listwise", "fiml", "stop"), verbose = TRUE, corArgs = list(), principalDirection = FALSE, unlock = FALSE, transform = c("none", "rank", "quantile"), ...) bootnet_LoGo(data, corMethod = c("cor", "cov", "cor", "npn", "cor_auto"), missing = c("pairwise", "listwise", "fiml", "stop"), verbose = TRUE, corArgs = list(), principalDirection = FALSE, unlock = FALSE, transform = c("none", "rank", "quantile"), ...) bootnet_graphicalVAR(data, tuning = 0.5, verbose = TRUE, principalDirection = FALSE, missing = c("listwise", "stop"), unlock = FALSE, transform = c("none", "rank", "quantile"), ...) bootnet_ggmModSelect(data, tuning = 0, corMethod = c("cor", "cov", "cor_auto", "npn", "spearman"), missing = c("pairwise", "listwise", "fiml", "stop"), sampleSize = c("pairwise_average", "maximum", "minimum", "pairwise_maximum", "pairwise_minimum", "pairwise_average_v1.5", "pairwise_maximum_v1.5", "pairwise_minimum_v1.5"), verbose = TRUE, corArgs = list(), principalDirection = FALSE, start = c("glasso", "empty", "full"), stepwise = TRUE, nCores = 1, unlock = FALSE, nonPositiveDefinite = c("stop", "continue"), transform = c("none", "rank", "quantile"), ...) bootnet_piecewiseIsing(data, cutoff, missing = c("listwise", "stop"), verbose = TRUE, IsingDefault = c("IsingSampler", "IsingFit", "custom"), zeroThreshold = 1, minimalN = ncol(data) + 1, unlock = FALSE, ...) bootnet_SVAR_lavaan(data, verbose = TRUE, principalDirection = FALSE, missing = c("listwise", "stop"), criterion = "bic", eqThreshold = 1e-04, tempWhitelist, tempBlacklist, contWhitelist, contBlacklist, minimalModInd = 10, unlock = FALSE, transform = c("none", "rank", "quantile"), ...) bootnet_GGMncv(data, penalty = c("atan", "selo", "exp", "log", "sica", "scad", "mcp", "lasso"), corMethod = c("cor", "cov", "cor_auto", "npn", "spearman"), missing = c("pairwise", "listwise", "fiml", "stop"), sampleSize = c("pairwise_average", "maximum", "minimum", "pairwise_maximum", "pairwise_minimum", "pairwise_average_v1.5", "pairwise_maximum_v1.5", "pairwise_minimum_v1.5"), verbose = TRUE, corArgs = list(), principalDirection = FALSE, unlock = FALSE, nonPositiveDefinite = c("stop", "continue"), transform = c("none", "rank", "quantile"), ...)
data |
A data frame or matrix containing the raw data. Must be numeric, integer or ordered factors. |
default |
A string indicating the method to use. Specifying a
See details section for a more detailed description. |
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 |
tuning |
EBIC tuning parameter, used in 'EBICglasso', 'IsingFit', 'huge', 'mgm' and 'ggmModSelect' default sets. Note that the default value differs: 'EBICglasso', 'huge' and 'mgm' use 0.5, 'IsingFit' uses 0.25 and 'ggmModSelect uses 0. |
corMethod |
Correlation method, used in 'EBICglasso' and 'pcor' default sets. |
missing |
How to handle missing data? |
sampleSize |
How will sample size be computed in EBICglasso default set? The default |
corArgs |
A list with arguments for the function used defined by |
threshold |
Thresholding to use in partial correlation networks. Can be a fixed number to threshold all absolute edges below this value, |
refit |
Logical used in EBICglasso default set: should the estimated model structure be refitted without LASSO regularization? |
rule |
The rule to use to select an edge in nodewise estimation. |
split |
A function or character string ( |
method |
The estimation method used in the IsingSampler default set (see |
npn |
Logical, should nonparanormal be used in huge default set? |
criterion |
The criterion used in model selection. |
nFolds |
Number of folds used in k-fold cross-validation. |
type |
For mgm, see mgm or mgmfit; for relative importance networks, see |
level |
See |
order |
Order up until including which interactions are included in the model. See |
binarySign |
See |
normalized |
Should normalized relative importance be used in relative importance networks? |
structureDefault |
In relative importance networks, default set used to compute the graph structure. Any other arguments used (using ...) are sent to the graph estimator function as well. |
graphType |
|
alpha |
Significance level to test at. |
principalDirection |
Rescales variables according to the sign of the first eigen-vector. This will lead to most correlations to be positive (positive manifold), leading to negative edges to be substantively interpretable. |
stepwise |
Logical indicating if 'ggmModSelect' should use stepwise estimation. |
start |
See |
labels |
A character vector containing the node labels. If omitted the column names of the data are used. |
verbose |
Logical, currently only used when |
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. |
datatype |
|
checkNumeric |
Logical: should the data be checked to be numeric? |
lambda.min.ratio |
Minimal lambda ratio (LASSO tuning parameter) |
nlambda |
Number of LASSO tuning parameters to test |
nCores |
Number of cores to use in estimating networks |
.dots |
A list of arguments used in the estimation function set by a default set or by the |
... |
A list of arguments used in the estimation function set by a default set or by the |
.input |
Used internally in the bootnet function. Do not use. |
memorysaver |
Logical. If TRUE attempts to save memory (RAM) by removing some objects from the output. Used by bootnet by default for bootstraps. |
cutoff |
Cutoff score for sum-score to condition on when using |
IsingDefault |
Default set for Ising model structure estimation in piecewise Ising estimation. This is *experimental*! |
zeroThreshold |
Used in piecewise Ising estimation. Proportion of edges needed to be exactly 0 in pieces to set edge to zero in final network. This is *experimental*! |
minimalN |
Used in piecewise Ising estimation. Minimal sample sizes needed in piece estimation. This is *experimental*! |
eqThreshold |
Used in SVAR_lavaan estimation (stepup SVAR estimation). This is *experimental*! Maximum difference in criterion to decide if two models are equivalent (and select one at random). |
tempWhitelist |
Used in SVAR_lavaan estimation (step up SVAR estimation). This is *experimental*! Matrix with edges to be whitelisted in the temporal model. The matrix should contain two columns and a row for each edge. The elements should be characters indicating the variable names of each edge (from, to). |
tempBlacklist |
Used in SVAR_lavaan estimation (step up SVAR estimation). This is *experimental*! Matrix with edges to be blacklisted in the temporal model. The matrix should contain two columns and a row for each edge. The elements should be characters indicating the variable names of each edge (from, to). |
contWhitelist |
Used in SVAR_lavaan estimation (step up SVAR estimation). This is *experimental*! Matrix with edges to be whitelisted in the contemporaneous model. The matrix should contain two columns and a row for each edge. The elements should be characters indicating the variable names of each edge (from, to). |
contBlacklist |
Used in SVAR_lavaan estimation (step up SVAR estimation). This is *experimental*! Matrix with edges to be blacklisted in the contemporaneous model. The matrix should contain two columns and a row for each edge. The elements should be characters indicating the variable names of each edge (from, to). |
minimalModInd |
Minimal modification index to consider when adding parameters in SVAR search. |
adjacency |
An 'adjacency' matrix indicating the graph structure (zeroes indicate a missing edge). |
nonPositiveDefinite |
Set to |
unlock |
Set to |
transform |
Should data be transformed before estimate the network? |
penalty |
Penalty to use in the GGMncv methods. |
min_sum |
The minimum sum score that is artifically possible in the dataset. Defaults to -Inf. Set this only if you know a lower sum score is not possible in the data, for example due to selection bias. |
AND |
Logical, should an AND-rule (both regressions need to be significant) or OR-rule (one of the regressions needs to be significant) be used? |
The user can manually specify an estimation method by assigning a custom function to the 'fun'
argument. This function must take data as input and output an estimated network. Fhe functions bootnet_
correspond to the functions used when using default sets. E.g, default = "pcor"
sets fun = bootnet_pcor
. As the ...
leads to any argument to estimateNetwork
to be passed to the estimator function, the arguments described above in these estimator functions can be used for the appropriate default method. For example, if default = "pcor"
, the arguments of fun = bootnet_pcor
can be used in estimateNetwork
. IMPORTANT NOTE: DO NOT USE THE ESTIMATOR FUNCTIONS (e.g., fun = bootnet_pcor
) YOURSELF, THEY ARE ONLY INCLUDED HERE TO SHOW WHICH ARGUMENTS YOU CAN USE IN estimateNetwork
.
Sacha Epskamp <[email protected]>
Epskamp, S., Borsboom, D., & Fried, E. I. (2016). Estimating psychological networks and their accuracy: a tutorial paper. arXiv preprint, arXiv:1604.08462.
# BFI Extraversion data from psychTools package: library("psychTools") data(bfi) bfiSub <- bfi[,1:25] # Estimate network: Network <- estimateNetwork(bfiSub, default = "EBICglasso") ## Not run: # Some pointers: print(Network) # Estimated network: plot(Network, layout = 'spring') # Centrality indices: library("qgraph") centralityPlot(Network) # BIC model selection: Network_BIC <- estimateNetwork(bfiSub, default = "EBICglasso", tuning = 0) # Ising model: Network_BIC <- estimateNetwork(bfiSub, default = "IsingFit") ## End(Not run)
# BFI Extraversion data from psychTools package: library("psychTools") data(bfi) bfiSub <- bfi[,1:25] # Estimate network: Network <- estimateNetwork(bfiSub, default = "EBICglasso") ## Not run: # Some pointers: print(Network) # Estimated network: plot(Network, layout = 'spring') # Centrality indices: library("qgraph") centralityPlot(Network) # BIC model selection: Network_BIC <- estimateNetwork(bfiSub, default = "EBICglasso", tuning = 0) # Ising model: Network_BIC <- estimateNetwork(bfiSub, default = "IsingFit") ## End(Not run)
Simulates a GGM as described by Yin and Li (2011), using the Watts and Strogatz (1998) algorithm for generating the graph structure (see watts.strogatz.game
).
genGGM(Nvar, p = 0, nei = 1, parRange = c(0.5,1), constant = 1.5, propPositive = 0.5, clusters = NULL, graph = c("smallworld","random", "scalefree", "hub", "cluster"))
genGGM(Nvar, p = 0, nei = 1, parRange = c(0.5,1), constant = 1.5, propPositive = 0.5, clusters = NULL, graph = c("smallworld","random", "scalefree", "hub", "cluster"))
Nvar |
Number of nodes |
p |
Rewiring probability if graph = "smallworld" or "cluster", or connection probability if graph = "random". If cluster, can add multiple p's for each cluster, e.g., "c(.1, .5)" |
nei |
Neighborhood (see |
parRange |
Range of partial correlation coefficients to be originally sampled. |
constant |
A constant as described by Yin and Li (2011). |
propPositive |
Proportion of edges to be set positive. |
clusters |
Number of clusters if graph = "cluster" |
graph |
Type of graph to simulate |
Sacha Epskamp <[email protected]>
Yin, J., and Li, H. (2011). A sparse conditional gaussian graphical model for analysis of genetical genomics data. The annals of applied statistics, 5(4), 2630.
Watts, D. J., & Strogatz, S. H. (1998). Collective dynamics of ‘small-world’ networks. nature, 393(6684), 440-442.
Generates data given a partial correlation network. Data can be made ordinal by using a threshold model with equally spaced thresholds.
ggmGenerator(ordinal = FALSE, nLevels = 4, skewFactor = 1, type = c("uniform", "random"), missing = 0)
ggmGenerator(ordinal = FALSE, nLevels = 4, skewFactor = 1, type = c("uniform", "random"), missing = 0)
ordinal |
Logical, should ordinal data be generated? |
nLevels |
Number of levels used in ordinal data. |
skewFactor |
How skewed should ordinal data be? 1 indicates uniform data and higher values increase skewedness. |
type |
Should thresholds for ordinal data be sampled at random or determined uniformly? |
missing |
Proportion of data that should be simulated to be missing. |
Sacha Epskamp <[email protected]>
Uses IsingSampler
to generate the data.
IsingGenerator(...)
IsingGenerator(...)
... |
Arguments passed to |
A function with as first argument the sample size and as second argument a named list, with element graph
encoding a weights matrix and element intercepts
encoding thresholds.
Sacha Epskamp <[email protected]>
This function makes a 'multiverse' plot of bootstrap results. Every row indicates an edge and every column a bootstrap; colors are in line of the edge strength as drawn with plot.bootnetResult
.
multiverse(x, labels = FALSE)
multiverse(x, labels = FALSE)
x |
Results from |
labels |
Logical, should labels be printed next to the plot? |
Sacha Epskamp <[email protected]>
This function can be used to run a simulation study on the performance of network estimation by varying sample size or any argument used as input to estimateNetwork
. The purpose of this function is to provide a way to assess the required sample size given a network structure, as well as to easily perform simulation studies. By default, the function uses genGGM
to simulate a chain graph or small-world network. See details for more information. The replicationSimulator
function instead assesses how well a network based on a second independent sample would replicate the network based on the first independent sample.
netSimulator( input = genGGM(Nvar = 10), nCases = c(50, 100, 250, 500, 1000, 2500), nReps = 100, nCores = 1, default, dataGenerator, ..., moreArgs = list(), moreOutput = list()) replicationSimulator( input = genGGM(Nvar = 10), nCases = c(50, 100, 250, 500, 1000, 2500), nReps = 100, nCores = 1, default, dataGenerator, ..., moreArgs = list())
netSimulator( input = genGGM(Nvar = 10), nCases = c(50, 100, 250, 500, 1000, 2500), nReps = 100, nCores = 1, default, dataGenerator, ..., moreArgs = list(), moreOutput = list()) replicationSimulator( input = genGGM(Nvar = 10), nCases = c(50, 100, 250, 500, 1000, 2500), nReps = 100, nCores = 1, default, dataGenerator, ..., moreArgs = list())
input |
Either a weights matrix, a list containing elements |
nCases |
The sample sizes to test for. |
nReps |
Number of repetitions per sampling level. |
nCores |
Number of cores to use. Set to more than 1 to use parallel computing. |
default |
Default set used (see |
dataGenerator |
A function that generates data. The first argument must be the sample size, the second argument must be the output of |
moreArgs |
A named list of arguments to be used when estimating the network, but which should not be interpreted as different conditions. Use this argument to assign arguments that require vectors. |
moreOutput |
List with functions that take the estimated weights matrix as first argument and the true weights matrix as second argument to produce some output. |
... |
Arguments used by |
*any* argument to estimateNetwork
can be used in a simulation study, with a vector (e.g., rule = c("AND","OR")
) specifying that both conditions are tested. Adding too many conditions can quickly make any simulation study intractible, so only vary some arguments! The dataGenerator
argument can be any function that generates data. Currently, only ggmGenerator
and IsingGenerator
are implemented in bootnet itself, which generates data given a Gaussian graphical model.
Sacha Epskamp <[email protected]>
# 5-node GGM chain graph: trueNetwork <- genGGM(5) # Simulate: Res <- netSimulator(trueNetwork, nReps = 10) # Results: Res # Plot: plot(Res) # BFI example: # Load data: library("psychTools") data(bfi) bfiData <- bfi[,1:25] # Estimate a network structure, with parameters refitted without LASSO regularization: library("qgraph") Network <- EBICglasso(cor_auto(bfiData), nrow(bfiData), refit = TRUE) # Simulate 100 repititions in 8 cores under different sampling levels: Sim1 <- netSimulator(Network, default = "EBICglasso", nCases = c(100,250,500), nReps = 100, nCores = 8) # Table of results: Sim1 # Plot results: plot(Sim1) # Compare different default set at two sampling levels: Sim2_EBICglasso <- netSimulator(Network, default = c("EBICglasso"), nCases = c(100,250,500), nReps = 100, nCores = 8) Sim2_pcor <- netSimulator(Network, default = c("pcor"), nCases = c(100,250,500), nReps = 100, nCores = 8) Sim2_huge <- netSimulator(Network, default = c("huge"), nCases = c(100,250,500), nReps = 100, nCores = 8) Sim2 <- rbind(Sim2_EBICglasso, Sim2_pcor, Sim2_huge) # Print results: Sim2 # Plot results: plot(Sim2, xfacet = "default", yvar = "correlation") # Difference using polychoric or pearson correlations in ordinal data: Sim3 <- netSimulator(Network, dataGenerator = ggmGenerator(ordinal = TRUE, nLevels = 4), default = "EBICglasso", corMethod = c("cor","cor_auto"), nCases = c(100,250, 500), nReps = 100, nCores = 8) # Print results: Sim3 # Plot results: plot(Sim3, color = "corMethod") # Ising model: trueNetwork <- read.csv('http://sachaepskamp.com/files/weiadj.csv')[,-1] trueNetwork <- as.matrix(trueNetwork) Symptoms <- rownames(trueNetwork) <- colnames(trueNetwork) Thresholds <- read.csv('http://sachaepskamp.com/files/thr.csv')[,-1] # Create an input list (intercepts now needed) input <- list(graph=trueNetwork,intercepts=Thresholds) # Simulate under different sampling levels: Sim4 <- netSimulator( input = input, default = "IsingFit", nCases = c(250,500,1000), nReps = 100, nCores = 8) # Results: Sim4 # Plot: plot(Sim4) # Compare AND and OR rule: Sim5 <- netSimulator( input = input, default = "IsingFit", nCases = c(250,500,1000), rule = c("AND","OR"), nReps = 100, nCores = 8) # Print: Sim5 # Plot: plot(Sim5, yfacet = "rule")
# 5-node GGM chain graph: trueNetwork <- genGGM(5) # Simulate: Res <- netSimulator(trueNetwork, nReps = 10) # Results: Res # Plot: plot(Res) # BFI example: # Load data: library("psychTools") data(bfi) bfiData <- bfi[,1:25] # Estimate a network structure, with parameters refitted without LASSO regularization: library("qgraph") Network <- EBICglasso(cor_auto(bfiData), nrow(bfiData), refit = TRUE) # Simulate 100 repititions in 8 cores under different sampling levels: Sim1 <- netSimulator(Network, default = "EBICglasso", nCases = c(100,250,500), nReps = 100, nCores = 8) # Table of results: Sim1 # Plot results: plot(Sim1) # Compare different default set at two sampling levels: Sim2_EBICglasso <- netSimulator(Network, default = c("EBICglasso"), nCases = c(100,250,500), nReps = 100, nCores = 8) Sim2_pcor <- netSimulator(Network, default = c("pcor"), nCases = c(100,250,500), nReps = 100, nCores = 8) Sim2_huge <- netSimulator(Network, default = c("huge"), nCases = c(100,250,500), nReps = 100, nCores = 8) Sim2 <- rbind(Sim2_EBICglasso, Sim2_pcor, Sim2_huge) # Print results: Sim2 # Plot results: plot(Sim2, xfacet = "default", yvar = "correlation") # Difference using polychoric or pearson correlations in ordinal data: Sim3 <- netSimulator(Network, dataGenerator = ggmGenerator(ordinal = TRUE, nLevels = 4), default = "EBICglasso", corMethod = c("cor","cor_auto"), nCases = c(100,250, 500), nReps = 100, nCores = 8) # Print results: Sim3 # Plot results: plot(Sim3, color = "corMethod") # Ising model: trueNetwork <- read.csv('http://sachaepskamp.com/files/weiadj.csv')[,-1] trueNetwork <- as.matrix(trueNetwork) Symptoms <- rownames(trueNetwork) <- colnames(trueNetwork) Thresholds <- read.csv('http://sachaepskamp.com/files/thr.csv')[,-1] # Create an input list (intercepts now needed) input <- list(graph=trueNetwork,intercepts=Thresholds) # Simulate under different sampling levels: Sim4 <- netSimulator( input = input, default = "IsingFit", nCases = c(250,500,1000), nReps = 100, nCores = 8) # Results: Sim4 # Plot: plot(Sim4) # Compare AND and OR rule: Sim5 <- netSimulator( input = input, default = "IsingFit", nCases = c(250,500,1000), rule = c("AND","OR"), nReps = 100, nCores = 8) # Print: Sim5 # Plot: plot(Sim5, yfacet = "rule")
Plot, print and summary methods for netSimulator
output.
## S3 method for class 'netSimulator' plot(x, xvar = "factor(nCases)", yvar = c("sensitivity", "specificity", "correlation"), xfacet = "measure", yfacet = ".", color = NULL, ylim = c(0, 1), print = TRUE, xlab = "Number of cases", ylab, outlier.size = 0.5, boxplot.lwd = 0.5, style = c("fancy", "basic"), ...) ## S3 method for class 'netSimulator' print(x, digits = 2, ...) ## S3 method for class 'netSimulator' summary(object, digits = 2, ...) ## S3 method for class 'replicationSimulator' plot(x, yvar = c("correlation", "jaccard", "replicatedEdges", "replicatedZeroes"), ...) ## S3 method for class 'replicationSimulator' print(x, digits = 2, ...) ## S3 method for class 'replicationSimulator' summary(object, digits = 2, ...)
## S3 method for class 'netSimulator' plot(x, xvar = "factor(nCases)", yvar = c("sensitivity", "specificity", "correlation"), xfacet = "measure", yfacet = ".", color = NULL, ylim = c(0, 1), print = TRUE, xlab = "Number of cases", ylab, outlier.size = 0.5, boxplot.lwd = 0.5, style = c("fancy", "basic"), ...) ## S3 method for class 'netSimulator' print(x, digits = 2, ...) ## S3 method for class 'netSimulator' summary(object, digits = 2, ...) ## S3 method for class 'replicationSimulator' plot(x, yvar = c("correlation", "jaccard", "replicatedEdges", "replicatedZeroes"), ...) ## S3 method for class 'replicationSimulator' print(x, digits = 2, ...) ## S3 method for class 'replicationSimulator' summary(object, digits = 2, ...)
x |
Output of |
object |
Output of |
xvar |
String indicating the variable to be used on the x-axis. |
yvar |
String vector indicating the variable(s) to be used on the y-axis. |
xfacet |
String indicating the variable to be used on the horizontal facets (or |
yfacet |
String indicating the variable to be used on the vertical facets (or |
color |
String indicating the variable to be used in coloring boxplots. |
ylim |
Y-axis limits. |
print |
Logical, should the plot be printed? This helps printing the plots to PDF files. |
digits |
Number of digits to be used in print and summary method. |
xlab |
X-axis label |
ylab |
Y-axis label. Defaults to combining the values in |
outlier.size |
Size of the outliers as plotted in boxplots. |
boxplot.lwd |
Line width of the boxplots |
style |
|
... |
Arguments sent to |
Sacha Epskamp <[email protected]>
This function simply returns NULL
.
null(...)
null(...)
... |
Anything |
Sacha Epskamp <[email protected]>
null("Not NULL")
null("Not NULL")
This function can be used to plot bootnet results by plotting all bootstrapped statistics as line or by plotting confidence intervals.
## S3 method for class 'bootnet' plot(x, statistics, plot, graph, CIstyle = c( "quantiles", "SE"), rank = FALSE, sampleColor = "darkred", samplelwd = 1, meanColor = "black", meanlwd = 0.5, bootColor = "black", bootAlpha = 0.01, bootlwd = 0.9, areaAlpha = 0.1, order = c("id", "sample", "mean"), decreasing = TRUE, perNode = FALSE, legendNcol = 2, labels = TRUE, legend = TRUE, subsetRange = c(100, 0), area = !perNode, alpha = 0.05, onlyNonZero = FALSE, differenceShowValue, differenceEdgeColor = TRUE, verbose = TRUE, panels = TRUE, split0 = FALSE, prop0 = ifelse(split0, TRUE, FALSE), prop0_cex = 1, prop0_alpha = 0.8, prop0_minAlpha = 0.25, subset, ...)
## S3 method for class 'bootnet' plot(x, statistics, plot, graph, CIstyle = c( "quantiles", "SE"), rank = FALSE, sampleColor = "darkred", samplelwd = 1, meanColor = "black", meanlwd = 0.5, bootColor = "black", bootAlpha = 0.01, bootlwd = 0.9, areaAlpha = 0.1, order = c("id", "sample", "mean"), decreasing = TRUE, perNode = FALSE, legendNcol = 2, labels = TRUE, legend = TRUE, subsetRange = c(100, 0), area = !perNode, alpha = 0.05, onlyNonZero = FALSE, differenceShowValue, differenceEdgeColor = TRUE, verbose = TRUE, panels = TRUE, split0 = FALSE, prop0 = ifelse(split0, TRUE, FALSE), prop0_cex = 1, prop0_alpha = 0.8, prop0_minAlpha = 0.25, subset, ...)
x |
A |
statistics |
The types of statistics to plot.Defaults to |
plot |
Character string indicating what to plot. Can be |
graph |
If multipe graphs are estimated, which graph should be plotted? Currently used for |
CIstyle |
Style of CIs to construct. |
rank |
Logical, should plots show rank of statistics instead of statistics? |
sampleColor |
Color of the original sample line |
samplelwd |
Line width of the original sample line |
bootColor |
Color of the bootstrap lines |
bootAlpha |
Alpha of the bootstrap lines |
bootlwd |
Line width of the bootstrap lines |
areaAlpha |
Alpha of the area |
order |
String indicating how to order nodes. |
decreasing |
Logical indicating if the ordering is decreasing or increasing. |
perNode |
Logical, should centrality estimates per node be plotted instead of correlation with original parameter. Only used in node and person drop bootstrap. |
legendNcol |
Number of columns in the legend if |
labels |
Logical, should labels be plotted? |
legend |
Logical, should the legend be plotted? |
subsetRange |
Range in percentages of the x-axis in node and person drop plots. |
area |
Logical, should the confidence area be plotted? |
alpha |
Signifiance level used in |
onlyNonZero |
Logical used when |
differenceShowValue |
Logical used when |
differenceEdgeColor |
Logical used when |
verbose |
Should expected alpha be printed? |
panels |
Logical, should panel titles be printed? |
meanColor |
Color of the bootstrap means. |
meanlwd |
Line width of the bootstrap means |
split0 |
Logical. When set to TRUE, the displayed intervals are based on occasions when the parameter was not estimated to be zero, and an extra box is added indicating the number of times a parameter is estimated to be zero. |
prop0 |
Logical, should boxes indicating the proportion of times parameters were estimated to be zero be added to the plot? |
prop0_cex |
Size of the boxes indicating number of times a parameter was set to zero. |
prop0_alpha |
Transparency of the boxes indicating number of times a parameter was set to zero. |
prop0_minAlpha |
Minimal transparency of the *lines* of plotted intervals as the proportion of times an edge was not included goes to 0. |
subset |
Vector indicating labels of nodes to include in the plot. This can be used to show, for example, only edges related to one particular node. |
... |
Not used. |
A ggplot2
object.
Sacha Epskamp <[email protected]>
Plots the graph using the qgraph package and the qgraph
function. Defined as qgraph::qgraph(x[['graph']],labels=x[['labels']],...)
## S3 method for class 'bootnetResult' plot(x, graph, weighted, signed, directed, labels, layout = "spring", parallelEdge = TRUE, cut = 0, theme = "colorblind", bootIncludeOverwrite = TRUE, ...)
## S3 method for class 'bootnetResult' plot(x, graph, weighted, signed, directed, labels, layout = "spring", parallelEdge = TRUE, cut = 0, theme = "colorblind", bootIncludeOverwrite = TRUE, ...)
x |
A |
graph |
Numeric or string indicating which graph to plot. Only needed when multiple graphs are estimated. For example, when using |
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. |
labels |
Labels of the nodes. Defaults to the column names of the data if missing. |
layout |
Placement of the nodes. See |
parallelEdge |
Should edges in directed networks be plotted parallel? See |
cut |
Should scaling in width and saturation of edges be split? See |
theme |
Theme of the edge and node colors. See |
bootIncludeOverwrite |
Logical. If |
... |
Arguments sent to |
Sacha Epskamp <[email protected]>
Prints a short overview of the results of bootnet
## S3 method for class 'bootnet' print(x, ...) ## S3 method for class 'bootnetResult' print(x, ...) ## S3 method for class 'bootnetResult' summary(object, ...)
## S3 method for class 'bootnet' print(x, ...) ## S3 method for class 'bootnetResult' print(x, ...) ## S3 method for class 'bootnetResult' summary(object, ...)
x |
A |
object |
A |
... |
Not used. |
Sacha Epskamp <[email protected]>
Creates a data frame (wrapped as tbl_df
) containing summarized results of the bootstraps.
## S3 method for class 'bootnet' summary(object, graph, statistics = c("edge", "intercept", "strength", "closeness", "betweenness", "distance"), perNode = FALSE, rank = FALSE, tol = sqrt(.Machine$double.eps), ...)
## S3 method for class 'bootnet' summary(object, graph, statistics = c("edge", "intercept", "strength", "closeness", "betweenness", "distance"), perNode = FALSE, rank = FALSE, tol = sqrt(.Machine$double.eps), ...)
object |
A |
graph |
Numeric or string indicating which graph to summarize. Only needed when multiple graphs are estimated. For example, when using |
statistics |
The types of statistics to include in the summary table |
perNode |
Logical, should centrality estimates per node be plotted instead of correlation with original parameter. Only used in node and person drop bootstrap. |
rank |
Logical, should plots show rank of statistics instead of statistics? |
tol |
Tolerance level for assuming an edge is set to zero. |
... |
Not used. |
A tbl_df
(data frame) containing summarized statistics.
Sacha Epskamp <[email protected]>
Functions to transform data
quantile_transformation(x) rank_transformation(x, ties.method = c("average", "first", "last", "random", "max", "min"))
quantile_transformation(x) rank_transformation(x, ties.method = c("average", "first", "last", "random", "max", "min"))
x |
A dataset |
ties.method |
See |
Sacha Epskamp <[email protected]>