This function is just like stm's searchK, but it uses tidyverse and allows a formula for prevalence. Adapted from Julia Silge's blog.

my_searchK(documents, K, prevalence = ~1, seed1 = 19, ...)

Arguments

documents

Quanteda dfm object.

K

Numeric vector of numbers of topics to try.

prevalence

Formula of topic prevalence.

seed1

Random seed to use.

...

Other arguments to pass to stm::stm.

Value

A tibble with the metrics output by searchK, plus a column for the fitted model for each value of K tried.