Cleans the text item via clean_text_responses(), tokenises with the
package's shared internal tokeniser (reused rather than a second
tidytext-based tokeniser, so LDA and term_frequency() can never
drift on cleaning/stop-word rules), casts the token counts to a
document-term matrix with tidytext::cast_dtm(), and fits
topicmodels::LDA().
Arguments
- data
A data.frame of responses.
- roles
A list with
item, the text/textarea item id.- options
A list;
k(topic count, default4L– a demonstration value, not a recommendation; seevignette("text-analysis")'s topic- modelling section fortopicmodels::perplexity()-based selection),seed(default42L),stop_words(passed through to the tokeniser).- instrument
Optional
sframeinstrument, passed toclean_text_responses()for item-type validation.
Value
A runner-contract result list: test = "topic_model_lda",
table (topic/term/beta/rank, top 10 terms per topic), fit (a
runtime-only list holding the LDA model object and the document-row-to-
respondent mapping needed by extract_quotes()), apa, prompt. On
failure: list(test = "topic_model_lda", error = <message>).