Learn R Programming

MLBC (version 0.2.1)

ols_bcm_topic: Multiplicative bias-corrected OLS for topic models (BCM-Topic)

Description

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

Usage

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

# S3 method for default ols_bcm_topic( Y, Q = NULL, W, S, B, k, data = parent.frame(), intercept = TRUE, ... )

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

Value

An object of class mlbc_fit and mlbc_bcm_topic with:

  • coef: bias-corrected coefficient estimates

  • vcov: adjusted variance-covariance matrix

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

Examples

Run this code
# 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 multiplicative bias correction
kappa <- mean(1.0 / lda_data[, 1]) * sqrt(nrow(lda_data))
S <- matrix(c(1.0, 0.0), nrow = 1)

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

Run the code above in your browser using DataLab