Skip to content

Instantly share code, notes, and snippets.

@philohistoria
Created September 10, 2017 05:17
Show Gist options
  • Save philohistoria/48bb4a2f7bcb8d87ee6493f34e45f36a to your computer and use it in GitHub Desktop.
Save philohistoria/48bb4a2f7bcb8d87ee6493f34e45f36a to your computer and use it in GitHub Desktop.
Simplest workflow for STM R package
library(stm)
data <- read.csv("pol.csv")
processedtest <- textProcessor(data$documents, metadata = data)
outtest <- prepDocuments(processedtest$documents, processedtest$vocab, processedtest$meta)
poliblogPrevFit <- stm(documents = out$documents, vocab = out$vocab, K = 20, prevalence =~ rating + s(day), max.em.its = 10, data = out$meta, init.type = "Spectral")
prep <- estimateEffect(1:20 ~ rating + s(day), poliblogPrevFit, meta = out$meta, uncertainty = "Global")
plot(prep, "day", method = "continuous", topics = 7, model = z, printlegend = FALSE, xaxt = "n", xlab = "Time (2008)")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment