PCA

##           eigenvalue percentage of variance cumulative percentage of variance
## comp 1  9.872375e+00           3.404267e+01                          34.04267
## comp 2  4.245656e+00           1.464019e+01                          48.68287
## comp 3  3.552780e+00           1.225096e+01                          60.93383
## comp 4  3.024566e+00           1.042954e+01                          71.36337
## comp 5  2.199136e+00           7.583229e+00                          78.94660
## comp 6  1.570087e+00           5.414095e+00                          84.36069
## comp 7  9.453714e-01           3.259901e+00                          87.62059
## comp 8  7.519478e-01           2.592923e+00                          90.21352
## comp 9  5.021676e-01           1.731612e+00                          91.94513
## comp 10 3.707297e-01           1.278378e+00                          93.22351
## comp 11 3.209538e-01           1.106737e+00                          94.33025
## comp 12 3.134460e-01           1.080848e+00                          95.41109
## comp 13 2.419820e-01           8.344208e-01                          96.24551
## comp 14 1.904572e-01           6.567489e-01                          96.90226
## comp 15 1.400744e-01           4.830152e-01                          97.38528
## comp 16 1.295375e-01           4.466811e-01                          97.83196
## comp 17 1.231099e-01           4.245169e-01                          98.25648
## comp 18 8.939553e-02           3.082604e-01                          98.56474
## comp 19 8.502571e-02           2.931921e-01                          98.85793
## comp 20 7.839598e-02           2.703309e-01                          99.12826
## comp 21 5.608581e-02           1.933993e-01                          99.32166
## comp 22 4.998430e-02           1.723597e-01                          99.49402
## comp 23 4.504667e-02           1.553334e-01                          99.64935
## comp 24 3.617093e-02           1.247273e-01                          99.77408
## comp 25 3.148988e-02           1.085858e-01                          99.88267
## comp 26 2.510756e-02           8.657778e-02                          99.96924
## comp 27 4.597449e-03           1.585327e-02                          99.98510
## comp 28 4.322041e-03           1.490359e-02                         100.00000
## comp 29 1.946983e-30           6.713734e-30                         100.00000

dat_tx_dim%>%
    dplyr::select(dim1,dim2,dim3,dim4,dim5,dim6) %>%
    single_imputation() %>%
    estimate_profiles(1:6, 
                      variances = c("equal", "varying"),
                      covariances = c("zero", "varying"),
                      package = c( "Mclust","MplusAutomation")
                      ) %>%
    compare_solutions(statistics = c("AIC", "BIC"))
## Warning in (function (data, modelName = NULL, nboot = 999, level = 0.05, : some
## model(s) could not be fitted!
## Warning: Mclust could not estimate model 6 with 6 classes.
## Warning: 
## One or more analyses resulted in warnings! Examine these analyses carefully: model_6_class_6

## Warning: 
## One or more analyses resulted in warnings! Examine these analyses carefully: model_6_class_6
## Compare tidyLPA solutions:
## 
##  Model Classes AIC      BIC      Warnings
##  1     1       26984.51 27044.61         
##  1     2       26942.05 27037.21         
##  1     3       26456.96 26587.18         
##  1     4       25851.59 26016.87         
##  1     5       25800.97 26001.31         
##  1     6       25314.75 25550.15         
##  6     1       27014.51 27149.74         
##  6     2       24248.01 24523.48         
##  6     3       22766.05 23181.75         
##  6     4       22152.89 22708.83         
##  6     5       21718.33 22414.52         
##  6     6                         Warning 
## 
## 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.

LPA

## 
##   1   2   3   4   5 
## 356 101 133 183 333

Cleaner table

V1 V2 V3 V4 V5
class 1.000 2.000 3.000 4.000 5.000
y00_04 259.550 120.840 371.320 1022.790 176.680
y05_09 330.350 81.530 469.230 1316.820 155.500
y10_14 404.280 68.030 466.270 1445.080 118.050
y15_19 479.360 72.420 608.750 1660.780 141.550
inc 2.000 1.000 2.000 2.000 1.000
pnhw00 0.225 0.047 0.103 0.340 0.204
pnhw12 0.364 0.086 0.151 0.686 0.382
pnhw19 0.362 0.087 0.149 0.652 0.337
pnhb00 0.050 0.010 0.192 0.015 0.028
pnhb12 0.109 0.019 0.507 0.040 0.085
pnhb19 0.112 0.020 0.468 0.043 0.093
phisp00 0.111 0.249 0.058 0.050 0.107
phisp12 0.469 0.885 0.310 0.196 0.473
phisp19 0.458 0.883 0.346 0.204 0.502
mhhinc00 69435.730 44952.050 55647.210 122206.850 87850.250
mhhinc12 61365.650 39366.540 46719.060 113795.560 80018.050
mhhinc19 69856.540 43392.790 52155.720 128569.620 82852.420
pedu00 0.282 0.060 0.146 0.552 0.284
pedu12 0.303 0.070 0.153 0.600 0.300
pedu19 0.354 0.089 0.194 0.655 0.320
pop00 8.261 8.358 7.763 8.150 8.036
pop12 8.266 8.304 7.573 8.362 8.488
pop19 8.349 8.372 7.680 8.500 8.636
dev01 0.985 0.984 0.743 0.716 0.581
dev11 0.989 0.987 0.784 0.752 0.659
dev19 0.990 0.989 0.799 0.769 0.689
la00 0.431 0.369 0.240 0.293 0.105
la10 0.431 0.369 0.240 0.293 0.105
la19 0.498 0.377 0.278 0.336 0.164

Maps

#mapping the data
tmap_mode("view")
## tmap mode set to interactive viewing
dat_tx_dim_sf %>% 
  filter( city == "austin") %>% 
tm_shape()+
  tm_basemap("Esri.WorldStreetMap")+
  tm_polygons("class",legend.hist=T,
              style = "cat",
              palette = "Set2",
              alpha = .5,
              labels = c("One","Two" ,"Three", "Four","Five"))+
  tm_layout(title = "Austin", 
            legend.outside = T)+
  tm_view(view.legend.position = c("right","bottom"))+
  tm_scale_bar()
dat_tx_dim_sf %>% 
  filter( city == "dallas") %>% 
tm_shape()+
  tm_basemap("Esri.WorldStreetMap")+
  tm_polygons("class",legend.hist=T,
              style = "cat",
              palette = "Set2",
              alpha = .5,
              labels = c("One","Two" ,"Three", "Four","Five"))+
  tm_layout(title = "Dallas", 
            legend.outside = T)+
  tm_view(view.legend.position = c("right","bottom"))+
  tm_scale_bar()
dat_tx_dim_sf %>% 
  filter( city == "san_antonio") %>% 
tm_shape()+
  tm_basemap("Esri.WorldStreetMap")+
  tm_polygons("class",legend.hist=T,
              style = "cat",
              palette = "Set2",
              alpha = .5,
              labels = c("One","Two" ,"Three", "Four","Five"))+
  tm_layout(title = "San Antonio", 
            legend.outside = T)+
  tm_view(view.legend.position = c("right","bottom"))+
  tm_scale_bar()
dat_tx_dim_sf %>% 
  filter(city == "austin") %>% 
ggplot() +
  geom_sf()

dat_tx_dim_sf %>% 
  filter(city == "dallas") %>% 
ggplot() +
  geom_sf()

### facetwrap
#### SA prob 1

dat_tx_dim_sf %>% 
  filter(city == "san_antonio") %>% 
ggplot() +
  geom_sf(aes(fill = prob1))+
  facet_wrap(~class,nrow = 2)

#### SA prob 2

dat_tx_dim_sf %>% 
  filter(city == "san_antonio") %>% 
ggplot() +
  geom_sf(aes(fill = prob2))+
  facet_wrap(~class,nrow = 2)

SA prob 3

dat_tx_dim_sf %>% 
  filter(city == "san_antonio") %>% 
ggplot() +
  geom_sf(aes(fill = prob3))+
  facet_wrap(~class,nrow = 2)

SA prob 4

dat_tx_dim_sf %>% 
  filter(city == "san_antonio") %>% 
ggplot() +
  geom_sf(aes(fill = prob4))+
  facet_wrap(~class,nrow = 2)

SA prob 5

dat_tx_dim_sf %>% 
  filter(city == "san_antonio") %>% 
ggplot() +
  geom_sf(aes(fill = prob5))+
  facet_wrap(~class,nrow = 2)