View source: R/estimateNetwork.R
estimateNetwork | R Documentation |
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"), ...)
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 <mail@sachaepskamp.com>
Epskamp, S., Borsboom, D., & Fried, E. I. (2016). Estimating psychological networks and their accuracy: a tutorial paper. arXiv preprint, arXiv:1604.08462.
bootnet
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.