### Example from ?ggm ###
# Load bfi data from psych package:
library("psychTools")
data(bfi)
# Also load dplyr for the pipe operator:
library("dplyr")
# Let's take the agreeableness items, and gender:
ConsData <- bfi %>%
select(A1:A5, gender) %>%
na.omit # Let's remove missingness (otherwise use Estimator = "FIML)
# Define variables:
vars <- names(ConsData)[1:5]
# Let's fit an empty GGM:
mod0 <- ggm(ConsData, vars = vars)
# Run the model:
mod0 <- mod0 %>% runmodel
# Labels:
labels <- c(
"indifferent to the feelings of others",
"inquire about others' well-being",
"comfort others",
"love children",
"make people feel at ease")
# Plot the CIs:
CIplot(mod0, "omega", labels = labels, labelstart = 0.2)
### Example from ?gvar ###
library("dplyr")
library("graphicalVAR")
beta <- matrix(c(
0,0.5,
0.5,0
),2,2,byrow=TRUE)
kappa <- diag(2)
simData <- graphicalVARsim(50, beta, kappa)
# Form model:
model <- gvar(simData)
# Evaluate model:
model <- model %>% runmodel
# Plot the CIs:
CIplot(model, "beta")
Run the code above in your browser using DataLab