Travis-CI Build Status AppVeyor Build Status

A Shiny Application for Structural Topic Models

This app enables interactive validation, interpretation and visualisation of Structural Topic Models (STM). In case you are not familiar with STM, the package vignette is an excellent starting point. In contrast to stmgui, which also allows to preprocess text data and fit models, stminsights is focused more on making your life easier after these steps.

How to Install

You can download and install the app by running devtools::install_github('methodds/stminsights').

For Windows users installing from github requires proper setup of Rtools, for which a tutorial is available here.

How to Use

After installing stminsights run stminsights::run_stminsights() to launch the shiny app in your browser. Afterwards you can upload an .RData file which should include:

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.


out <- list(documents =,
            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)


After launching stminsights and uploading the file, all objects are automatically imported and you can select which models and effect estimates to analyze.

How to Deploy on Shiny Server

Deploying stminsights to your own shiny server is pretty simple: 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.

To test stminsights on my server, download stm_poliblog5k.RData here and upload it at


To cite package stminsights in publications please use:

  Carsten Schwemmer (2018). stminsights: A Shiny Application for Inspecting
  Structural Topic Models. R package version 0.1.2.

A BibTeX entry for LaTeX users is:

    title = {stminsights: A Shiny Application for Inspecting Structural Topic Models},
    author = {Carsten Schwemmer},
    year = {2018},
    note = {R package version 0.1.2},
    url = {},