mx_data <- df_wide %>%
select(starts_with("Suppression_"), age_c, female, education_c, income_c) %>%
as.data.frame()
outcome_vars <- c("Suppression_Year_3", "Suppression_Year_4",
"Suppression_Year_5", "Suppression_Year_6")
covariate_vars <- c("age_c", "female", "education_c", "income_c")
manifest_vars <- c(outcome_vars, covariate_vars)
latent_vars <- c("i", "s")
model <- mxModel(
"LGCM_TIC",
type = "RAM",
manifestVars = manifest_vars,
latentVars = latent_vars,
mxData(observed = mx_data, type = "raw"),
mxPath(from = "i", to = outcome_vars,
free = FALSE, values = c(1, 1, 1, 1)),
mxPath(from = "s", to = outcome_vars,
free = FALSE, values = c(0, 1, 2, 3)),
mxPath(from = "one", to = c("i", "s"),
free = TRUE, values = c(3.0, 0.1),
labels = c("mean_i", "mean_s")),
mxPath(from = "one", to = outcome_vars,
free = FALSE, values = 0),
mxPath(from = "one", to = covariate_vars,
free = TRUE, values = c(0, 0.5, 0, 0),
labels = c("mean_age_c", "mean_female",
"mean_edu_c", "mean_inc_c")),
mxPath(from = "i", arrows = 2, free = TRUE, values = 0.3,
labels = "var_i"),
mxPath(from = "s", arrows = 2, free = TRUE, values = 0.05,
labels = "var_s"),
mxPath(from = "i", to = "s", arrows = 2, free = TRUE, values = -0.03,
labels = "cov_is"),
mxPath(from = outcome_vars, arrows = 2,
free = TRUE, values = 0.3,
labels = c("resvar", "resvar", "resvar", "resvar")),
mxPath(from = covariate_vars, arrows = 2, free = TRUE,
values = c(1, 0.25, 1, 0.5),
labels = c("var_age_c", "var_female",
"var_edu_c", "var_inc_c")),
mxPath(from = "age_c", to = "female", arrows = 2, free = TRUE,
values = 0, labels = "cov_age_fem"),
mxPath(from = "age_c", to = "education_c", arrows = 2, free = TRUE,
values = 0, labels = "cov_age_edu"),
mxPath(from = "age_c", to = "income_c", arrows = 2, free = TRUE,
values = 0, labels = "cov_age_inc"),
mxPath(from = "female", to = "education_c", arrows = 2, free = TRUE,
values = 0, labels = "cov_fem_edu"),
mxPath(from = "female", to = "income_c", arrows = 2, free = TRUE,
values = 0, labels = "cov_fem_inc"),
mxPath(from = "education_c", to = "income_c", arrows = 2, free = TRUE,
values = 0, labels = "cov_edu_inc"),
mxPath(from = "age_c", to = "i", free = TRUE, values = 0.05,
labels = "b_age_i"),
mxPath(from = "female", to = "i", free = TRUE, values = 0,
labels = "b_fem_i"),
mxPath(from = "education_c", to = "i", free = TRUE, values = 0,
labels = "b_edu_i"),
mxPath(from = "income_c", to = "i", free = TRUE, values = 0,
labels = "b_inc_i"),
mxPath(from = "age_c", to = "s", free = TRUE, values = -0.02,
labels = "b_age_s"),
mxPath(from = "female", to = "s", free = TRUE, values = 0,
labels = "b_fem_s"),
mxPath(from = "education_c", to = "s", free = TRUE, values = 0,
labels = "b_edu_s"),
mxPath(from = "income_c", to = "s", free = TRUE, values = 0,
labels = "b_inc_s")
)
model <- mxModel(model,
mxBounds(c("var_i", "var_s", "resvar"), min = 0.001))
fit <- mxRun(model)
summary(fit)