build_network(method = "pcor"), or for short build_pcor(), estimates
a partial correlation network of numeric variables. The edge between two
variables is their partial correlation given all the others, read from
the inverse of the correlation matrix, without regularisation (Epskamp &
Fried, 2018).
Unregularised partial correlations are noisy when there are many
variables for the number of observations, and they cannot be estimated
when the correlation matrix is singular (more variables than
observations, or collinear ones): that raises an error, and a
near-singular matrix a warning. build_glasso() estimates a sparse
network in those cases.
Arguments
- data
The variables: a data frame with one row per observation and one column per variable, or a square symmetric correlation or covariance matrix, which needs the sample size in
params(as inparams = list(n = 250)). Non-numeric columns are set aside; a frame of two or more character or factor columns and fewer than two numeric ones is read as sequences and turned into per-row state counts first. A column namedridis set aside; columns with non-syntactic names, all-missing and constant columns, and rows with a missing value are dropped, each with a message; fewer than 2 variables or 3 complete rows raise an error.- actor
The id column naming whose observation each row is (a person). With
level, the decomposition groups by it; without, it is set aside, not modelled. DefaultNULL.- level
Multilevel decomposition, with
actor:"between"estimates the network of person means,"within"the network of deviations from them, and"both"returns the two as anetobject_ml. DefaultNULL(no decomposition).- ...
Further arguments for
build_network().methodcannot be given (error of classnestimate_bad_input).- cor_method
"pearson"(default),"spearman"or"kendall", passed tostats::cor().- predictability
Whether to compute each node's predictability (the R-squared of the node on its neighbours). It is stored on the network, and
cograph::splot()draws it as a ring around each node. DefaultTRUE.- metadata_cols
Columns to keep as the network's metadata (covariates), never read as variables. Default
NULL.- group
A column to split the data by: one network per value, returned as a
netobject_group. DefaultNULL.- scaling
Rescaling applied to the weights after estimation, in the order given:
"minmax"rescales the weights to run from 0 to 1, over every cell for the transition methods (tna's rule, so with no zero cell the smallest weight becomes 0) and over the non-zero weights, into (0, 1], for the other methods,"max"divides by the largest absolute weight,"rank"replaces the non-zero weights by their ranks, and"normalize"makes each row's absolute weights sum to 1; an undirected network whose matrix it makes asymmetric becomes directed, so both of a pair's values are kept as edges. Zero weights stay zero under every option. Combine them as inc("rank", "minmax"). DefaultNULL(none).- threshold
Weights whose absolute value is below this are set to zero. Default
0(none).- labels
New display labels for the nodes, applied after estimation: a two-column data frame (
name,label), a named character vectorc(name = "label")or a named list. It rewrites the node labels and the weight matrix's dimnames; nodes not listed keep their names. DefaultNULL.- params
Settings for the estimator, as a named list, such as
n, the sample size whendatais a correlation or covariance matrix. The network stores them, sobootstrap_network()re-estimates with the same settings. Defaultlist().
Value
A netobject (a netobject_group with group, a netobject_ml
with level = "both"), as build_network() returns it.
References
Epskamp, S., & Fried, E. I. (2018). A tutorial on regularized partial correlation networks. Psychological Methods, 23(4), 617–634. doi:10.1037/met0000167
See also
build_network() for every method; build_cor(),
build_glasso() and build_ising() for the other association
networks.
Examples
build_network(srl_strategies, method = "pcor")
#> Partial Correlation Network (unregularised) [undirected]
#> Sample size: 250
#> Weights: [-0.235, 0.502] | +21 / -15 edges
#>
#> Strongest edges (10 of 36):
#> from to weight
#> Time_Mgmt Effort_Reg 0.502
#> Monitoring Evaluating 0.432
#> Evaluating Organization 0.406
#> Planning Time_Mgmt 0.397
#> Elaboration Organization 0.380
#> Evaluating Effort_Reg 0.330
#> Planning Evaluating 0.283
#> Monitoring Elaboration 0.274
#> Organization Rehearsal 0.274
#> Planning Monitoring 0.268
#>
#> extract_edges(include_self = TRUE) lists every edge; extract_transition_matrix() gives the weight matrix.
#>
#> Predictability (R²):
#> Evaluating 0.456 ████████████████████████████████████████
#> Monitoring 0.393 ███████████████████████████████████
#> Organization 0.387 ██████████████████████████████████
#> Time_Mgmt 0.377 █████████████████████████████████
#> Planning 0.372 █████████████████████████████████
#> Effort_Reg 0.336 █████████████████████████████
#> Elaboration 0.293 ██████████████████████████
#> Rehearsal 0.212 ███████████████████
#> Help_Seeking 0.110 ██████████
build_pcor(srl_strategies)
#> Partial Correlation Network (unregularised) [undirected]
#> Sample size: 250
#> Weights: [-0.235, 0.502] | +21 / -15 edges
#>
#> Strongest edges (10 of 36):
#> from to weight
#> Time_Mgmt Effort_Reg 0.502
#> Monitoring Evaluating 0.432
#> Evaluating Organization 0.406
#> Planning Time_Mgmt 0.397
#> Elaboration Organization 0.380
#> Evaluating Effort_Reg 0.330
#> Planning Evaluating 0.283
#> Monitoring Elaboration 0.274
#> Organization Rehearsal 0.274
#> Planning Monitoring 0.268
#>
#> extract_edges(include_self = TRUE) lists every edge; extract_transition_matrix() gives the weight matrix.
#>
#> Predictability (R²):
#> Evaluating 0.456 ████████████████████████████████████████
#> Monitoring 0.393 ███████████████████████████████████
#> Organization 0.387 ██████████████████████████████████
#> Time_Mgmt 0.377 █████████████████████████████████
#> Planning 0.372 █████████████████████████████████
#> Effort_Reg 0.336 █████████████████████████████
#> Elaboration 0.293 ██████████████████████████
#> Rehearsal 0.212 ███████████████████
#> Help_Seeking 0.110 ██████████