# \donttest{
# Load bfi data from psych package:
library("psychTools")
data(bfi)
# Also load dplyr for the pipe operator:
library("dplyr")
# Let's take the extroversion items, and gender:
ExData <- bfi %>%
select(E1:E5, gender) %>%
na.omit # Let's remove missingness (otherwise use Estimator = "FIML)
# Define variables:
vars <- names(ExData)[1:5]
# Saturated estimation:
mod_saturated <- ggm(ExData,
vars = vars,
groups = "gender")
# Partial prune model:
mod_partial <- mod_saturated
partialprune
# Obtain the networks:
getmatrix(mod_partial, "omega")
# Differences:
getmatrix(mod_partial, "omega")[[1]] -
getmatrix(mod_partial, "omega")[[2]]
# Difference detected in edge 4 - 5
# }
Run the code above in your browser using DataLab