discursive {discursive}R Documentation

Compute discursive sophistication for a set of open-ended responses

Description

This function takes a data frame (data) containing a set of open-ended responses (openends) to compute the three components of discursive sophistication (size, range, and constraint) and combines them in a single scale. See Kraft (2023) for details.

Usage

discursive(
  data,
  openends,
  meta,
  args_textProcessor = NULL,
  args_prepDocuments = NULL,
  args_stm = NULL,
  keep_stm = TRUE,
  dictionary,
  remove_duplicates = FALSE,
  type = c("scale", "average", "average_scale", "product"),
  progress = TRUE
)

Arguments

data

A data frame.

openends

A character vector containing variable names of open-ended responses in data.

meta

A character vector containing topic prevalence covariates included in data. See stm::stm() for details.

args_textProcessor

A named list containing additional arguments passed to stm::textProcessor().

args_prepDocuments

A named list containing additional arguments passed to stm::prepDocuments().

args_stm

A named list containing additional arguments passed to stm::stm().

keep_stm

Logical. If TRUE function returns output of stm::textProcessor(), stm::prepDocuments(), and stm::stm().

dictionary

A character vector containing dictionary terms to flag conjunctions and exclusive words. May include regular expressions.

remove_duplicates

Logical. If TRUE duplicates in dictionary are removed.

type

The method of combining the three components, must be "scale", "average", "average_scale", or "product". The default is "scale", which creates an additive index that is re-scaled to mean 0 and standard deviation 1. Alternatively, "average" creates the same additive index without re-scaling; "average_scale" re-scales each individual component to mean 0 and standard deviation 1 before creating the additive index; "product" creates a multiplicative index.

progress

Logical. Shows progress bar if TRUE.

Value

A list containing the measure of discursive sophistication and the underlying components in a data frame, as well as the output of stm::textProcessor(), stm::prepDocuments(), and stm::stm().

Examples

discursive(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),
           dictionary = dict_sample)

[Package discursive version 0.1.1 Index]