Nosferican / Econometrics.jl

Econometrics in Julia
https://nosferican.github.io/Econometrics.jl/dev
ISC License
69 stars 19 forks source link

Show F-test on first stage #32

Open pdeffebach opened 4 years ago

pdeffebach commented 4 years ago

Is your feature request related to a problem? Please describe. My problem set asked me for the F-test of a first stage of a 2SLS estimator. Unfortunately I can't report it based off of the output from fit.

julia> s = fit(EconometricModel, @formula(y ~ (x ~ w)), df)
Continuous Response Model
Number of observations: 500
Null Loglikelihood: -964.26
Loglikelihood: -638.83
R-squared: NaN
LR Test: 650.86 ∼ χ²(1) ⟹  Pr > χ² = 0.0000
Formula: y ~ 1 + (x ~ w)
Variance Covariance Estimator: OIM
──────────────────────────────────────────────────────────────────────────
                 PE         SE      t-value  Pr > |t|       2.50%   97.50%
──────────────────────────────────────────────────────────────────────────
(Intercept)  0.0266044  0.0393261  0.676507    0.4990  -0.0506615  0.10387
x            1.48562    0.331753   4.4781      <1e-5    0.833812   2.13743
──────────────────────────────────────────────────────────────────────────

Describe the solution you'd like Ideally we should print the F-test.

Additional context Looking at the docs, it looks like we print the F-test for the random effects estimator. I think we just need to report it for the more basic case as well.

Nosferican commented 4 years ago

The current show method uses the LR test in favor of the Wald test for those models. However, you should be able to get the Wald test by calling

W, F, p = Econometrics.wald(s)
if !isnan(p)
    println(Econometrics.@sprintf("Wald: %.2f ∼ F(%i, %i) ⟹ Pr > F = %.4f", W, Econometrics.params(F)..., p))
end

Let me know if that works in your case. I could consider making it print both the LR test and the Wald test for the default show or export and document wald.

pdeffebach commented 4 years ago

Thanks! I didn't realize that wald was available, thanks!

I think it would be nice to print the F of the first stage, it's so visible in Stata that I (and I'm sure others) would expect to see it.

Nosferican commented 4 years ago

I could add a line in the default show of IV to include the First Stage Wald Test...