Search code examples
rtopic-modelingtopicmodels

R STM Topic Proportion table


I'm trying to make a table for my STM model just like this.

enter image description here

I am new to R programming language and STM.

I have been searching in the documentation about this and do not know if there is a function that makes just like this format or if I have to manually make it like this.

Can I get some example on how to make a table like this and where can I get Topic Proportions in % and if the topic has Appeared in Literate or not?


Solution

  • As for expected topic proportion tables, the STM packages gives you a few options. For example, once you've generated your stm topic model object, you can pass the model through plot.STM(mod, type = "summary", main = "title") where mod is your stored model object, summary is the default table that this function generates, showing the expected proportion of the text corpus that belongs to a given topic (STM package, Roberts et al., 2018), and main = "title" is simply an optional command you can use to label your figure. Alternatively, you can also pass your stored topic model through plot(mod, type = "summary") for a similar result.

    As for extracting the exact % expected proportion by topic, I've had a similar question myself. Below is a custom workaround that I've recently implemented using the make.dt function from STM which outputs topic proportions by document.

    # custom proportion extraction proportions_table <- make.dt(mod) summarize_all(proportions_table, mean)