find_stm {Twitmo}R Documentation

Find best STM/CTM

Description

Gridsearch for optimal K for your STM/CTM

Usage

find_stm(data, search_space = seq(4, 20, by = 2), ...)

Arguments

data

Either a pooled dfm object returned by pool_tweets or a named list of pre-processed tweets for stm modeling returned by fit_stm.

search_space

Vector with number of topics to compare different models.

...

Additional parameters passed to searchK

Details

Wrapper function around searchK for pooled dfm objects returned by pool_tweets and prepped stm documents returned by fit_stm.

Value

Plot with different metrics compared.

See Also

searchK

searchK

Examples

## Not run: 

library(Twitmo)

# load tweets (included in package)
mytweets <- load_tweets(system.file("extdata", "tweets_20191027-141233.json", package = "Twitmo"))

# Pool tweets into longer pseudo-documents
pool <- pool_tweets(data = mytweets)
pooled_dfm <- pool$document_term_matrix

# compare different K for CTM
find_stm(pooled_dfm, search_space = seq(1, 10, 1))

# OR

# compare different K for STM
prepped_stm <- stm_model$prep
find_stm(prepped_stm, search_space = seq(4, 16, by = 2))

## End(Not run)

[Package Twitmo version 0.1.2 Index]