View source: R/mgm_error_metrics.R
| mgm_error_metrics | R Documentation |
Fits a Mixed Graphical Model and extracts prediction error metrics.
mgm_error_metrics(data, type, level, k = 2)
data |
Data frame or matrix with the data. |
type |
Character vector of variable types ("g", "c", "p"). |
level |
Integer vector of variable levels. |
k |
Order of interactions (default: 2). |
A list with the node predictability of the model: errorCon, a
data frame with the RMSE and R2 of the continuous variables; errorCat,
a data frame with the accuracy (CC) and normalized accuracy (nCC) of the
categorical variables; and, when all variables are of the same kind, a
named vector R2 or nCC ready to be used as the pie argument of
qgraph.
set.seed(123)
n <- 300
f1 <- rnorm(n)
f2 <- 0.3 * f1 + rnorm(n)
items <- data.frame(
sapply(1:4, function(i) 0.7 * f1 + rnorm(n, 0, 0.7)),
sapply(1:4, function(i) 0.7 * f2 + rnorm(n, 0, 0.7))
)
names(items) <- c(paste0("A", 1:4), paste0("B", 1:4))
errors <- mgm_error_metrics(items, type = rep("g", 8), level = rep(1, 8))
errors$errorCon
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.