This app enables interactive validation, interpretation and visualization of Structural Topic Models (STM). Stminsights is focused on making your life easier after fitting your STM models. In case you are not familiar with the STM package, the corresponding vignette is an excellent starting point.
You can download and install the latest development version of stminsights by running devtools::install_github('cschwem2er/stminsights')
.
For Windows users installing from github requires proper setup of Rtools.
stminsights can also be installed from CRAN by running install.packages('stminsights')
.
After loading stminsights you can launch the shiny app in your browser:
You can then upload a .RData
file which should include:
stm
objects.estimateEffect
objects.out
which was used to fit your stm models.As an example, the following code fits two models and estimates effects for the Political Blog Corpus. Afterwards, all objects required for stminsights are stored in stm_poliblog5k.RData
.
library(stm)
out <- list(documents = poliblog5k.docs,
vocab = poliblog5k.voc,
meta = poliblog5k.meta)
poli <- stm(documents = out$documents,
vocab = out$vocab,
data = out$meta,
prevalence = ~ rating * s(day),
K = 20)
prep_poli <- estimateEffect(1:20 ~ rating * s(day), poli,
meta = out$meta)
poli_content <- stm(documents = out$documents,
vocab = out$vocab,
data = out$meta,
prevalence = ~ rating + s(day),
content = ~ rating,
K = 15)
prep_poli_content <- estimateEffect(1:15 ~ rating + s(day), poli_content,
meta = out$meta)
save.image('stm_poliblog5k.RData')
After launching stminsights and uploading the file, all objects are automatically imported and you can select which models and effect estimates to analyze.
In addition to the shiny app, several helper functions are available, e.g. get_effects()
for storing effect estimates in a tidy dataframe.
To deploy stminsights to your own shiny server, place the file app.R
, which is located at inst/app
of this package, to a folder in your server directory and you should be good to go.