find_stm: Find best STM/CTM

Description Usage Arguments Details Value See Also Examples

View source: R/fit_stm.R

Description

Gridsearch for optimal K for your STM/CTM

Usage

1
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
## 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)

Twitmo documentation built on Dec. 11, 2021, 10:01 a.m.