Skip to contents

Reports how well each node is predicted by the others in a fitted network. For Gaussian graphical models this is the closed-form variance explained (R-squared) from the precision matrix and needs no data. For the nodewise models (ising_fit(), ising_sampler(), mgm_fit()) it requires the data and reports R-squared for Gaussian nodes and classification accuracy (CC) plus normalized accuracy (nCC) for binary nodes.

Prediction selects the original modeled columns, independently of display labels. Binary MGM categories use the levels recorded when fitting, including numeric codes such as 1/2; unseen categories are refused.

Usage

net_predict(x, data = NULL, ...)

Arguments

x

A psychnet object.

data

The data the network was estimated from; required for the nodewise models (ising / IsingSampler / mgm), ignored for the GGMs.

...

Unused.

Value

A tidy data.frame, one row per node, with columns node, type ("gaussian" or "binary"), metric ("R2" or "nCC"), predictability, and accuracy (classification accuracy for binary nodes, NA for Gaussian).

Examples

S <- 0.4^abs(outer(1:6, 1:6, "-"))
net_predict(ebic_glasso(cor_matrix = S, n = 250))
#>   node     type metric predictability accuracy
#> 1   V1 gaussian     R2      0.1568160       NA
#> 2   V2 gaussian     R2      0.2711166       NA
#> 3   V3 gaussian     R2      0.2711166       NA
#> 4   V4 gaussian     R2      0.2711166       NA
#> 5   V5 gaussian     R2      0.2711166       NA
#> 6   V6 gaussian     R2      0.1568160       NA