10.4 Disgression: Another approach to model group differences

We could also model the group difference by including the group as an exogenous variable in our model. Group is thus treated as a predictor of the mean of the latent factor.

model_effect <- 'factor =~ V1+V2+V3+V4

factor ~ effect*group
'

We again estimate the model as above.

fit_model_cor25_effect <- cfa(model_effect, data_frame_cor25, meanstructure=T, effect.coding = T)
fit_model_cor50_effect <- cfa(model_effect, data_frame_cor50, meanstructure=T, effect.coding = T)
fit_model_cor80_effect <- cfa(model_effect, data_frame_cor80, meanstructure=T, effect.coding = T)
fit_model_cor99_effect <- cfa(model_effect, data_frame_cor99, meanstructure=T, effect.coding = T)
summary(fit_model_cor25_effect, fit.measures = T, standardized = T)
summary(fit_model_cor50_effect, fit.measures = T, standardized = T)
summary(fit_model_cor80_effect, fit.measures = T, standardized = T)
summary(fit_model_cor99_effect, fit.measures = T, standardized = T)

The parameter estimate of the regression should be (close to) \(\beta = .2\), i.e., going from group 1 to group 2 results in a change of .2 of the latent mean.

#get parameter estimates for the model R1 (correlations .25)
estimates_regression_25 <- parameterestimates(fit_model_cor25_effect)

#give the unstandardized beta, i.e., the effect
estimates_regression_25[estimates_regression_25$label == 'effect', 'est']
## [1] 0.19
#get parameter estimates for the model R2 (correlations .50)
estimates_regression_50 <- parameterestimates(fit_model_cor50_effect)

#give the unstandardized beta, i.e., the effect
estimates_regression_50[estimates_regression_50$label == 'effect', 'est']
## [1] 0.19
#get parameter estimates for the model R3 (correlations .80)
estimates_regression_80 <- parameterestimates(fit_model_cor80_effect)

#give the unstandardized beta, i.e., the effect
estimates_regression_80[estimates_regression_80$label == 'effect', 'est']
## [1] 0.22
#get parameter estimates for the model R4 (correlations .99)
estimates_regression_99 <- parameterestimates(fit_model_cor99_effect)

#give the unstandardized beta, i.e., the effect
estimates_regression_99[estimates_regression_99$label == 'effect', 'est']
## [1] 0.18
# if you want the value for p, z or the standard error, use the respective column label
# e.g. -> estimates25[estimates25$label == 'effect', 'pvalue']