Economist Year in Review Part 3

The previous post clustered articles based on the Countries included in the article. This post will cluster countries based on the topics models created.

library(topicmodels)
library(qgraph)
country.mat = read.csv("/Users/sweiss/Google Drive/countrymatrix.csv")
country.mat = country.mat[, -1]
load("/users/sweiss/google drive/EconomistNoCountryld100.Rda")
theta = posterior(ld.100)$topics
country.mat.1 = country.mat[, -which(colSums(country.mat) < 10)]

country.topics = data.frame()
for (i in 1:dim(country.mat.1)[2]) {
    country.topics = rbind(country.topics, colMeans(theta[which(country.mat.1[, 
        i] > 0), ]))
}
rownames(country.topics) = colnames(country.mat.1)

qgraph(cor(t(country.topics), use = "pairwise"), layout = "spring", labels = rownames(country.topics), 
    label.cex = 1, label.color = "blue", label.scale = FALSE, minimum = 0.25)

plot of chunk unnamed-chunk-1

x = hclust(dist((country.topics)), method = "complete")
plot(x)

plot of chunk unnamed-chunk-2