ols_bca_topic: Additive bias-corrected OLS for topic models (BCA-Topic)

View source: R/topicmodels.R

ols_bca_topicR Documentation

Additive bias-corrected OLS for topic models (BCA-Topic)

Description

Bias-corrected additive estimator for topic model regression. This method applies additive bias correction to regressions that include topic proportions as covariates, accounting for estimation uncertainty in the topic model.

Usage

ols_bca_topic(
  Y,
  Q = NULL,
  W,
  S,
  B,
  k,
  data = parent.frame(),
  intercept = TRUE,
  ...
)

## Default S3 method:
ols_bca_topic(
  Y,
  Q = NULL,
  W,
  S,
  B,
  k,
  data = parent.frame(),
  intercept = TRUE,
  ...
)

## S3 method for class 'formula'
ols_bca_topic(
  Y,
  Q = NULL,
  W,
  S,
  B,
  k,
  data = parent.frame(),
  intercept = TRUE,
  ...
)

Arguments

Y

numeric response vector, or a one-sided formula

Q

numeric matrix of additional controls (if Y is numeric)

W

numeric matrix of document-term frequencies

S

numeric matrix of topic loadings

B

numeric matrix of topic-word distributions

k

numeric; bias correction parameter

data

data frame (if Y is a formula)

intercept

logical; if TRUE, includes an intercept term

...

additional arguments

Value

An object of class mlbc_fit and mlbc_bca_topic with:

  • coef: bias-corrected coefficient estimates

  • vcov: adjusted variance-covariance matrix

Examples

# Load topic model dataset
data(topic_model_data)

# Extract components
Y <- topic_model_data$estimation_data$ly
Z <- as.matrix(topic_model_data$covars)
theta_full <- as.matrix(topic_model_data$theta_est_full)
beta_full <- as.matrix(topic_model_data$beta_est_full)
lda_data <- as.matrix(topic_model_data$lda_data)

# Apply additive bias correction
kappa <- mean(1.0 / lda_data[, 1]) * sqrt(nrow(lda_data))
S <- matrix(c(1.0, 0.0), nrow = 1)

fit <- ols_bca_topic(Y, Z, theta_full, S, beta_full, k = kappa)
summary(fit)

MLBC documentation built on Aug. 8, 2025, 7:31 p.m.