### Number of recommended classes
dat_dim5%>%
dplyr::select(dim1,dim2,dim3,dim4,dim5) %>%
single_imputation() %>%
estimate_profiles(1:5,
variances = c("equal", "varying"),
covariances = c("zero", "varying")
) %>%
compare_solutions(statistics = c("AIC", "BIC"))
## Compare tidyLPA solutions:
##
## Model Classes AIC BIC Warnings
## 1 1 22779.16 22829.63
## 1 2 22316.16 22396.90
## 1 3 22146.09 22257.12
## 1 4 21554.44 21695.75
## 1 5 19867.71 20039.30 Warning
## 6 1 22799.16 22900.10
## 6 2 19397.94 19604.85
## 6 3 18655.28 18968.17
## 6 4 17571.80 17990.67
## 6 5 17184.59 17709.44
##
## Best model according to AIC is Model 6 with 5 classes.
## Best model according to BIC is Model 6 with 5 classes.
##
## An analytic hierarchy process, based on the fit indices AIC, AWE, BIC, CLC, and KIC (Akogul & Erisoglu, 2017), suggests the best solution is Model 6 with 5 classes.
y1 <- dat_dim5 %>%
dplyr::select(dim1,dim2,dim3,dim4,dim5) %>%
single_imputation() %>%
poms() %>%
estimate_profiles(3,
variances = "varying",
covariances = "varying") %>%
plot_profiles()
y2<- dat_dim5 %>%
dplyr::select(dim1,dim2,dim3,dim4,dim5) %>%
single_imputation() %>%
poms() %>%
estimate_profiles(4,package = "MplusAutomation",
variances = "varying",
covariances = "varying") %>%
plot_profiles()
## Warning:
## One or more analyses resulted in warnings! Examine these analyses carefully: model_6_class_4
v2 <- dat_dim5 %>%
dplyr::select(dim1,dim2,dim3,dim4,dim5) %>%
single_imputation() %>%
poms() %>%
estimate_profiles(4,package = "MplusAutomation",
variances = "varying",
covariances = "varying") %>%
get_data()
## Warning:
## One or more analyses resulted in warnings! Examine these analyses carefully: model_6_class_4
dat_dim5$classv2 <- v2$Class
table(dat_dim5$classv2)
##
## 1 2 3 4
## 22 672 278 177
tracts_sf <- tracts(state = "TX",
county = c("453","113","029"),
year = "2010",
progress_bar = F)
tracts_sf_sub <- county_subdivisions(
state = "TX",
county = c("453","113","029"),
year = "2010",
progress_bar = F)
tracts_sf <- tracts_sf %>%
transmute(
geoid = as.numeric(GEOID10),
county = COUNTYFP10,
geometry = geometry
)
dat_dim5sf <- left_join(tracts_sf,dat_dim5)
## Joining, by = "geoid"
dat_dim5sf <- st_as_sf(dat_dim5sf)
dat2sub <- data.frame(dat2$geoid,dat2$geometry)
dat2sub <- dat2sub %>%
transmute(
geoid = dat2.geoid,
geometry = geometry
)
dat2sub <- st_as_sf(dat2sub)
dat_dimsf <- left_join(dat_dim5,dat2sub)
## Joining, by = "geoid"
#bpsw <- bpsw[!duplicated(bpsw$geoid),]
dat_dimsf <- dat_dimsf %>%
distinct()
#dat_dimsf <- dat_dim[!duplicated(dat_dimsf$geoid),]
dat_dimsf <- st_as_sf(dat_dimsf)
tmap_mode("view")
## tmap mode set to interactive viewing
dat_dim5sf %>%
filter( city == "austin") %>%
tm_shape()+
tm_basemap("Esri.WorldStreetMap")+
tm_polygons("classv2",legend.hist=T,
style = "cat",
palette = "Set2",
alpha = .5,
labels = c("One","Two" ,"Three", "Four"))+
tm_layout(title = "Austin",
legend.outside = T)+
tm_view(view.legend.position = c("right","bottom"))+
tm_scale_bar()
dat_dim5sf %>%
filter( city == "dallas") %>%
tm_shape()+
tm_basemap("Esri.WorldStreetMap")+
tm_polygons("classv2",legend.hist=T,
style = "cat",
palette = "Set2",
alpha = .5,
labels = c("One","Two" ,"Three", "Four"))+
tm_layout(title = "Dallas",
legend.outside = T)+
tm_view(view.legend.position = c("right","bottom"))+
tm_scale_bar()
dat_dim5sf %>%
filter( city == "san_antonio") %>%
tm_shape()+
tm_basemap("Esri.WorldStreetMap")+
tm_polygons("classv2",legend.hist=T,
style = "cat",
palette = "Set2",
alpha = .5,
labels = c("One","Two" ,"Three", "Four"))+
tm_layout(title = "San Antonio",
legend.outside = T)+
tm_view(view.legend.position = c("right","bottom"))+
tm_scale_bar()
#### trouble shoot county subdivision
tracts_sf %>%
filter(county == "029") %>%
tm_shape()+
tm_polygons()
tracts_sf_sub %>%
filter(COUNTYFP10 == "029") %>%
tm_shape() +
tm_polygons("NAME10",
style = "cat",
palette = "Set2")
y3<- dat_dim5 %>%
dplyr::select(dim1,dim2,dim3,dim4,dim5) %>%
single_imputation() %>%
poms() %>%
estimate_profiles(5,package = "MplusAutomation",
variances = "varying",
covariances = "varying") %>%
plot_profiles()
## Warning:
## One or more analyses resulted in warnings! Examine these analyses carefully: model_6_class_5