DeclareDesign / estimatr

estimatr: Fast Estimators for Design-Based Inference
https://declaredesign.org/r/estimatr
Other
131 stars 20 forks source link

glance.iv_robust doesn't report first-stage statisctics #385

Closed Gedevan-Aleksizde closed 3 years ago

Gedevan-Aleksizde commented 3 years ago

I used iv_robust() with diagnostics = T, however glance() not report the first-stage statistics

library(estimatr)
library(fabricatr)
set.seed(42)
dat <- fabricate(
  N = 40,
  Y = rpois(N, lambda = 4),
  Z = rbinom(N, 1, prob = 0.4),
  D  = Z * rbinom(N, 1, prob = 0.8),
  X = rnorm(N),
  G = sample(letters[1:4], N, replace = TRUE)
)

fit <- iv_robust(Y ~ D + X | Z + X, data = dat, diagnostics = T)
glance(fit)
      r.squared adj.r.squared df.residual nobs se_type statistic    p.value statistic.weakinst
value 0.1442495     0.0979927          37   40     HC2   3.15632 0.05424511                 NA
      p.value.weakinst statistic.endogeneity p.value.endogeneity statistic.overid p.value.overid
value               NA                    NA                  NA               NA             NA

I found that a simple miss spelling causes this problem: The iv_robust object contains diagnostic_first_stage_fstatistic but glance.iv_robust() refers diagnostic_firststage_fstatistic, and other 2 elements are so on.

Gedevan-Aleksizde commented 3 years ago

I suggest: https://github.com/DeclareDesign/estimatr/pull/386

Gedevan-Aleksizde commented 3 years ago

Thanks