Block 5: Clustering

Week 6 · Measurement II · Imai §3.7 · about 4 min

NoteHow this works

Run each cell with Run Code, look at the output, then answer the question at the end of the block. Every cell is editable; Start Over resets it. Errors are information: read them.

We give both dimensions of each member’s score (a matrix, dwnom80 and dwnom112) to kmeans() and ask for 2 clusters, without telling it the party.

1. k-means with 2 clusters

2. Do the clusters match the parties?

Conclusion: In which Congress do the two clusters match the parties better?
In the 112th the clusters recover the parties almost perfectly. In the 80th, 62 Democrats fall into the "Republican" cluster: the algorithm never saw the party labels, and the parties were less ideologically separated.