Learn R Programming

valueprhr (version 0.1.0)

fit_mundlak_cre: Fit Mundlak Correlated Random Effects Model

Description

Fits a Mundlak (CRE) model that decomposes effects into within and between components, allowing for correlation between unit effects and regressors.

Usage

fit_mundlak_cre(panel_data, include_time_fe = TRUE, robust_se = TRUE)

Value

A list containing:

model

The fitted plm model object

summary

Model summary

panel_data_augmented

Panel data with Mundlak transformations

coeftest_robust

Robust coefficient tests

variance_components

Random effects variance components

metrics

In-sample evaluation metrics

Arguments

panel_data

Data frame in panel format.

include_time_fe

Logical. Include time fixed effects. Default TRUE.

robust_se

Logical. Compute robust standard errors. Default TRUE.

Details

The Mundlak transformation adds sector-level means of the regressors to a random effects model, allowing consistent estimation even when the random effects are correlated with the regressors.

Examples

Run this code
# \donttest{
if (requireNamespace("plm", quietly = TRUE)) {
  set.seed(123)
  panel <- data.frame(
    year = rep(2000:2009, 5),
    sector = rep(LETTERS[1:5], each = 10),
    log_direct = rnorm(50, 5, 0.5),
    log_production = rnorm(50, 5, 0.5)
  )
  panel$log_production <- panel$log_direct * 0.95 + rnorm(50, 0, 0.1)

  result <- fit_mundlak_cre(panel)
  print(result$variance_components)
}
# }

Run the code above in your browser using DataLab