as_networks: Promote a psychometric MCML result to a network group

View source: R/mcml_pc.R

as_networksR Documentation

Promote a psychometric MCML result to a network group

Description

as_networks() is the psychometric-network counterpart of as_tna. It promotes the cluster-level (macro) and within-cluster networks produced by build_mcml_pc into a single netobject_group, so the result flows into the same downstream verbs as any other group of networks (print(), summary(), plot(), net_centrality).

Usage

as_networks(x)

## S3 method for class 'mcml_pc'
as_networks(x)

## Default S3 method:
as_networks(x)

Arguments

x

An object to convert. The mcml_pc method (from build_mcml_pc) is the primary path.

Details

Where as_tna() promotes transition networks (directed, row-normalised, with initial probabilities) and re-wraps raw matrices, as_networks() promotes psychometric networks (undirected; correlation / partial-correlation / glasso). The macro and within-cluster components of an mcml_pc object are already full netobjects carrying their estimator, directedness and data, so this function assembles them into a group rather than re-wrapping matrices.

Value

A netobject_group: a named list whose first element is macro (the cluster-level network), followed by one netobject per non-singleton cluster.

The mcml_pc method returns a netobject_group; singleton clusters (no within-network) are dropped with a warning().

The default method returns the input unchanged if it is already a netobject_group, otherwise it errors.

See Also

build_mcml_pc to create the input, as_tna for the transition-network counterpart.

Examples

set.seed(1)
df <- as.data.frame(matrix(stats::rnorm(200 * 6), 200, 6))
names(df) <- c("a1", "a2", "a3", "b1", "b2", "b3")
clusters <- list(A = c("a1", "a2", "a3"), B = c("b1", "b2", "b3"))
fit <- build_mcml_pc(df, clusters, aggregation = "composite", method = "cor")
nets <- as_networks(fit)
nets
nets$macro$weights

Nestimate documentation built on July 11, 2026, 1:09 a.m.