Skip to contents

Cross-validated lasso (glmnet) of an outcome on the topic-proportion matrix (cf. stm::topicLasso). Identifies which topics predict the outcome.

Usage

topic_lasso(
  formula,
  model,
  data,
  family = "gaussian",
  nfolds = 10L,
  seed = 2138L,
  ...
)

Arguments

formula

outcome ~ . — the LHS names the outcome in data.

model

A faSTM fit (supplies the topic proportions).

data

Document-level data with the outcome, aligned to the documents.

family

glmnet family ("gaussian", "binomial", ...).

nfolds

CV folds.

seed

RNG seed.

...

Passed to glmnet::cv.glmnet().

Value

A faSTM_topiclasso with selected per-topic coefficients.