#stemie_profs<-compare_models_mplus(stemie_esm, cognitive_engagement, behavioral_engagement, affective_engagement, starts = c(100, 20))
#compare_models_lpa(stemie_esm, cognitive_engagement, behavioral_engagement, affective_engagement)
#compare_models_lpa(stemie_esm, cognitive_engagement, behavioral_engagement, affective_engagement, prior_control = T)
#stemie_profs[[1]] %>%
#gather(key,val, -n_profiles) %>%
#mutate(val = as.numeric(val)) %>%
#ggplot(aes(x=n_profiles, y=val, color=key, group=key)) +
#geom_line() +
#geom_point()
m1<-create_profiles_mplus(stemie_esm, cognitive_engagement, behavioral_engagement, affective_engagement, n_profiles=6, model=1, return_save_data = T)
## This first list item is the model output and the second is the save data with class probabilities.
plot_profiles_mplus(m1, to_center=TRUE, to_scale = TRUE)
## Warning: attributes are not identical across measure variables;
## they will be dropped

m7<-create_profiles_lpa(stemie_esm, cognitive_engagement, behavioral_engagement, affective_engagement, n_profiles=6, model=1)
## Fit varying means, equal variances, covariances fixed to 0 (Model 1) model with 6 profiles.
## LogLik is 9578.878
## AIC is 19209.756
## CAIC is 19391.66
## BIC is 19365.66
## SABIC is 19283.048
## ICL is 20031.927
## Entropy is 0.909
plot_profiles_lpa(m7, to_center=TRUE, to_scale = TRUE)
## Warning: attributes are not identical across measure variables;
## they will be dropped

m2<-create_profiles_mplus(stemie_esm, cognitive_engagement, behavioral_engagement, affective_engagement, n_profiles=5, model=1, return_save_data = T)
## This first list item is the model output and the second is the save data with class probabilities.
plot_profiles_mplus(m2, to_center=TRUE, to_scale = TRUE)
## Warning: attributes are not identical across measure variables;
## they will be dropped

m8<-create_profiles_lpa(stemie_esm, cognitive_engagement, behavioral_engagement, affective_engagement, n_profiles=5, model=1)
## Fit varying means, equal variances, covariances fixed to 0 (Model 1) model with 5 profiles.
## LogLik is 9670.222
## AIC is 19384.444
## CAIC is 19538.363
## BIC is 19516.363
## SABIC is 19446.461
## ICL is 20146.475
## Entropy is 0.914
plot_profiles_lpa(m8, to_center=TRUE, to_scale = TRUE)
## Warning: attributes are not identical across measure variables;
## they will be dropped

m3<-create_profiles_mplus(stemie_esm, cognitive_engagement, behavioral_engagement, affective_engagement, n_profiles=4, model=2, return_save_data = T)
## This first list item is the model output and the second is the save data with class probabilities.
plot_profiles_mplus(m3, to_center=TRUE, to_scale = TRUE)
## Warning: attributes are not identical across measure variables;
## they will be dropped

m8<-create_profiles_lpa(stemie_esm, cognitive_engagement, behavioral_engagement, affective_engagement, n_profiles=4, model=2)
## Fit varying means, equal variances and covariances (Model 2) model with 4 profiles.
## LogLik is 10276.326
## AIC is 20594.653
## CAIC is 20741.576
## BIC is 20720.576
## SABIC is 20653.851
## ICL is 22081.478
## Entropy is 0.81
## Warning in create_profiles_lpa(stemie_esm, cognitive_engagement,
## behavioral_engagement, : Some profiles are associated with no assignments.
## Interpret this solution with caution and consider other models.
plot_profiles_lpa(m8, to_center=TRUE, to_scale = TRUE)
## Warning: attributes are not identical across measure variables;
## they will be dropped

m4<-create_profiles_mplus(stemie_esm, cognitive_engagement, behavioral_engagement, affective_engagement, n_profiles=5, model=2, return_save_data = T)
## This first list item is the model output and the second is the save data with class probabilities.
plot_profiles_mplus(m4, to_center=TRUE, to_scale = TRUE)
## Warning: attributes are not identical across measure variables;
## they will be dropped

m9<-create_profiles_lpa(stemie_esm, cognitive_engagement, behavioral_engagement, affective_engagement, n_profiles=5, model=2)
## Fit varying means, equal variances and covariances (Model 2) model with 5 profiles.
## LogLik is 9547.821
## AIC is 19145.641
## CAIC is 19320.549
## BIC is 19295.549
## SABIC is 19216.115
## ICL is 19818.528
## Entropy is 0.927
plot_profiles_lpa(m9, to_center=TRUE, to_scale = TRUE)
## Warning: attributes are not identical across measure variables;
## they will be dropped

m5<-create_profiles_mplus(stemie_esm, cognitive_engagement, behavioral_engagement, affective_engagement, n_profiles=6, model=2, return_save_data = T)
## This first list item is the model output and the second is the save data with class probabilities.
plot_profiles_mplus(m5, to_center=TRUE, to_scale = TRUE)
## Warning: attributes are not identical across measure variables;
## they will be dropped

m55<-create_profiles_mplus(stemie_esm, cognitive_engagement, behavioral_engagement, affective_engagement, n_profiles=7, model=2, return_save_data = T)
## This first list item is the model output and the second is the save data with class probabilities.
plot_profiles_mplus(m55, to_center=TRUE, to_scale = TRUE)
## Warning: attributes are not identical across measure variables;
## they will be dropped

#m5 %>%
#pluck(2) %>%
#select(COGNITIV: AFFECTIV, C) %>%
#group_by(C) %>%
#summarise_all(mean, na.rm=T)
#r<-m5 %>%
#pluck(2)
#fit<-manova(cbind(COGNITIV, BEHAVIOR, AFFECTIV) ~ as.factor(r$C), data=r)
#summary(fit, test="Pillai")
#summary.aov(fit)
#aov1<-aov(COGNITIV ~ C, data = r)
#summary(aov1)
#TukeyHSD(aov(r$COGNITIV ~ as.factor(r$C)))
#aov2<-aov(BEHAVIOR ~ C, data = r)
#summary(aov2)
#TukeyHSD(aov(r$BEHAVIOR ~ as.factor(r$C)))
#aov3<-aov(AFFECTIV ~ C, data = r)
#summary(aov3)
#TukeyHSD(aov(r$AFFECTIV ~ as.factor(r$C)))