network.generalizability {EGAnet} | R Documentation |
Estimate the Generalizability of Network
Description
General function to compute a network's predictive power on new data, following Haslbeck and Waldorp (2018) and Williams and Rodriguez (2022) and using generalizability methods of data splitting, k-folds cross-validation, and leave-one-out cross-validation
Uses network.predictability
as the basis to then perform
generalizability methods over
Usage
network.generalizability(
data,
method = c("split", "cv", "loocv"),
number,
corr = c("auto", "cor_auto", "pearson", "spearman"),
na.data = c("pairwise", "listwise"),
model = c("BGGM", "glasso", "TMFG"),
algorithm = c("leiden", "louvain", "walktrap"),
uni.method = c("expand", "LE", "louvain"),
seed = NULL,
...
)
Arguments
data |
Matrix or data frame. Should consist only of variables to be used in the analysis. Can be raw data or a correlation matrix |
method |
Character (length = 1). Generalizability method. Available options:
|
number |
Numeric (length = 1).
Parameter to adjust the |
corr |
Character (length = 1).
Method to compute correlations.
Defaults to
For other similarity measures, compute them first and input them
into |
na.data |
Character (length = 1).
How should missing data be handled?
Defaults to
|
model |
Character (length = 1).
Defaults to
|
algorithm |
Character or
|
uni.method |
Character (length = 1).
What unidimensionality method should be used?
Defaults to
|
seed |
Numeric (length = 1).
Defaults to |
... |
Additional arguments to be passed on to
|
Details
This implementation of network predictability proceeds in several steps with important assumptions:
1. Network was estimated using (partial) correlations (not regression like the
mgm
package!)
2. Original data that was used to estimate the network in 1. is necessary to apply the original scaling to the new data
3. (Linear) regression-like coefficients are obtained by reserve engineering the
inverse covariance matrix using the network's partial correlations (i.e.,
by setting the diagonal of the network to -1 and computing the inverse
of the opposite signed partial correlation matrix; see EGAnet:::pcor2inv
)
4. Predicted values are obtained by matrix multiplying the new data with these coefficients
5. Dichotomous and polytomous data are given categorical values based on the original data's thresholds and these thresholds are used to convert the continuous predicted values into their corresponding categorical values
6. Evaluation metrics:
dichotomous — Accuracy or the percent correctly predicted for the 0s and 1s
polytomous — Accuracy based on the correctly predicting the ordinal category exactly (i.e., 1 = 1, 2, = 2, etc.) and a weighted accuracy such that absolute distance of the predicted value from the actual value (e.g., |prediction - actual| = 1) is used as the power of 0.5. This weighted approach provides an overall distance in terms of accuracy where each predicted value away from the actual value is given a harsher penalty (absolute difference = accuracy value): 0 = 1.000, 1 = 0.500, 2 = 0.2500, 3 = 0.1250, 4 = 0.0625, etc.
continuous — R-sqaured and root mean square error
Value
Returns a list containing:
node |
Node-wise metrics output from |
community |
Community-wise metrics output from |
Author(s)
Hudson Golino <hfg9s at virginia.edu> and Alexander P. Christensen <alexpaulchristensen@gmail.com>
References
Original Implementation of Node Predictability
Haslbeck, J. M., & Waldorp, L. J. (2018).
How well do network models predict observations? On the importance of predictability in network models.
Behavior Research Methods, 50(2), 853–861.
Derivation of Regression Coefficients Used (Formula 3)
Williams, D. R., & Rodriguez, J. E. (2022).
Why overfitting is not (usually) a problem in partial correlation networks.
Psychological Methods, 27(5), 822–840.
Examples
# Data splitting
network.generalizability(
data = wmt2[,7:24], method = "split",
number = 0.80 # 80/20 training/testing
)
# k-folds cross-validation
network.generalizability(
data = wmt2[,7:24], method = "cv",
number = 5 # 5-fold cross-validation
)
## Not run:
# Leave-one-out cross-validation
network.generalizability(
data = wmt2[,7:24], method = "loocv"
)
## End(Not run)