DS4PS / cpp-529-fall-2020

http://ds4ps.org/cpp-529-fall-2020/
0 stars 0 forks source link

Empty Cluster Models #15

Open ekmcintyre opened 4 years ago

ekmcintyre commented 4 years ago

I am not succeeding in creating the cluster models for the last part of the lab. Mine are completely empty.

image

lecy commented 4 years ago

It is a cluster model problem or a graphing problem?

What does your model produce?

fit <- Mclust( d3 )
summary( fit )
ekmcintyre commented 4 years ago

My model seems to be fine. image

lecy commented 4 years ago

Did you assign your new groups to your dorling object?

phx$cluster <- as.factor( fit$classification )

That is how the graphic assigns the colors: col="cluster"

tmap_mode("plot")
tmap_style("cobalt")
tm_shape( phx2, bbox=bb ) + 
  tm_polygons( col="cluster", palette="Accent"  )
ekmcintyre commented 4 years ago

I assigned cluster 2 and cluster 3.

d22 <- data.frame( dim1, dim2, dim3 )
fit2 <- Mclust( d22 )
summary( fit2 )
msp_dorling$cluster2 <- as.factor( fit2$classification )
d33 <- data.frame( d3$p18und12, d3$pflabf12, d3$hinc12 )
fit3 <- Mclust( d33 )
summary( fit3 )
msp_dorling$cluster3 <- as.factor( fit3$classification )`

Is "cluster" supposed to be from my original cluster groups? If so, I have that code earlier in my file.

set.seed( 1234 )
fit <- Mclust( d3 )
msp_dorling$cluster <- as.factor( fit$classification )
summary( fit )
lecy commented 4 years ago

@ekmcintyre That is correct.

ekmcintyre commented 4 years ago

Figured out the empty box was because of this code: tm_shape( msp_dorling, bbox=bb )

I didn't have a bb object to zoom in on the map. I just got rid of the bbox argument and the cluster map worked. image

lecy commented 4 years ago

Got it - you will need to find the edges around your core metro, then just change the xy/min/max values here:

bb <- st_bbox( c( xmin = -12519146, 
                  xmax = -12421368, 
                  ymax = 3965924,
                  ymin = 3899074 ), 
               crs = st_crs("+init=epsg:3395"))

That will let you create a bounding box specific to your city.

Which city is it, by the way?

ekmcintyre commented 4 years ago

New Orleans