discursive_size {discursive} | R Documentation |
Compute the size component of discursive sophistication
Description
This function takes a data frame (data
) containing a set of open-ended responses (openends
) and additional arguments passed to stm::textProcessor()
and stm::prepDocuments()
to estimate a structural topic model via stm::stm()
. The results of the the structural topic model are used to compute the relative number of topics raised in each open-ended response. The function returns a numeric vector of topic counts re-scaled to range from 0 to 1. See Kraft (2023) for details.
Usage
discursive_size(
data,
openends,
meta,
args_textProcessor = NULL,
args_prepDocuments = NULL,
args_stm = NULL,
keep_stm = TRUE,
progress = TRUE
)
Arguments
data |
A data frame. |
openends |
A character vector containing variable names of open-ended responses in |
meta |
A character vector containing topic prevalence covariates included in |
args_textProcessor |
A named list containing additional arguments passed to |
args_prepDocuments |
A named list containing additional arguments passed to |
args_stm |
A named list containing additional arguments passed to |
keep_stm |
Logical. If TRUE function returns output of |
progress |
Logical. Shows progress bar if TRUE. |
Value
A list containing the size component of discursive sophistication as well as the output of stm::textProcessor()
, stm::prepDocuments()
, and stm::stm()
.
Examples
discursive_size(data = cces,
openends = c(paste0("oe0", 1:9), "oe10"),
meta = c("age", "educ_cont", "pid_cont", "educ_pid", "female"),
args_prepDocuments = list(lower.thresh = 10),
args_stm = list(K = 25, seed = 12345))