build_cor() estimates a correlation network: an undirected graph of
variables in which each edge is the correlation of two variables. It is
build_network() with method = "cor". The correlation is Pearson's by
default; params = list(cor_method = "spearman") (or "kendall") passes
another method to stats::cor().
A correlation edge is a marginal association: it can come from a shared
link with a third variable. To separate direct from indirect links, use
build_pcor() or build_glasso(). Check the stability of the edges with
bootstrap_network().
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(), such asparams(cor_method,n),threshold,scalingorgroup.methodcannot be given: it is always"cor"(error of classnestimate_bad_input).
Value
A netobject (a netobject_group with group, a netobject_ml
with level = "both"), exactly as build_network() returns it: print
it for an overview, read the edges with extract_edges(), and draw it
with cograph::splot().
Examples
data(srl_strategies)
net <- build_cor(srl_strategies)