fit_stm {Twitmo} | R Documentation |
Fit STM (Structural topic model)
Description
Estimate a structural topic model
Usage
fit_stm(
data,
n_topics = 2L,
xcov,
remove_punct = TRUE,
stem = TRUE,
remove_url = TRUE,
remove_emojis = TRUE,
stopwords = "en",
...
)
Arguments
data |
Data frame of parsed tweets. Obtained either by using |
n_topics |
Integer with number of topics. |
xcov |
Either a \[stats]formula with an empty left-hand side specifying external covariates
(meta data) to use.e.g. |
remove_punct |
Logical. Indicates whether punctuation (includes Twitter hashtags and usernames) should be removed. Defaults to TRUE. |
stem |
Logical. If |
remove_url |
Logical. If |
remove_emojis |
Logical. If |
stopwords |
a character vector, list of character vectors, dictionary or collocations object. See pattern for details. Defaults to stopwords("english"). |
... |
Additional arguments passed to stm. |
Details
Use this to function estimate a STM from a data frame of parsed Tweets. Works with unpooled Tweets only. Pre-processing and fitting is done in one run.
Value
Object of class stm. Additionally, pre-processed documents are appended into a named list called "prep".
See Also
Examples
## Not run:
library(Twitmo)
# load tweets (included in package)
mytweets <- load_tweets(system.file("extdata", "tweets_20191027-141233.json", package = "Twitmo"))
# fit STM with tweets
stm_model <- fit_stm(mytweets, n_topics = 7,
xcov = ~ retweet_count + followers_count + reply_count +
quote_count + favorite_count,
remove_punct = TRUE,
remove_url = TRUE,
remove_emojis = TRUE,
stem = TRUE,
stopwords = "en")
## End(Not run)