Skip to content

Kleibergen-Paap test code broken; Effective F-statistic implementation #161

@apoorvalal

Description

@apoorvalal

K-P error

Computing the Kleibergen-Paap F-statistic using fitstat(mod, "kpr") produces the following error with the dev version of fixest. The equivalent computation in lfe works fine (and is identical to the documented ivreg2 version in stata).

Error in str2lang(value_raw): <text>:2:0: unexpected end of input
1: (+Intercept
   ^
Traceback:

1. fitstat(m_feols, "kpr")
2. kp_stat(x)
3. proj_on_U(x, Z)
4. resid(feols.fit(Z, U))
5. feols.fit(Z, U)
6. feols(env = env)
7. .xpd(rhs = fml[[3]])
8. value2stringCall(rhs, call = TRUE, check = check)
9. str2lang(value_raw)

MWE:

library(data.table); library(fixest); library(lfe)
set.seed(42)
N = 1e3
df = data.table(
  e = rnorm(N),
  z1 = rbinom(N, 1, 0.3),
  z2 = rnorm(N)
)
df[, x := 0.2 * z1 + 0.3 * z2 + e * 1.5][
    ,y := x + e]

# %%
m_felm = felm(y ~ 1 | 0 | (x ~ z1 + z2), df)
# KP F stat in LFE object / identical in stata's ivreg2
m_felm$stage1$rob.iv1fstat

# %%
m_feols = feols(y ~ 1 | x ~ z1 + z2, df)
fitstat(m_feols, "kpr")
# error

Effective F statistic

Also I was wondering if there's any interest in including the effective F statistic (which is identical to K-P in just-identified single-instrument+single-treatment settings - see [2] for details ).

As part of a review paper I'm working on with coauthors, I'm implementing the Pflueger-Montiel Olea Effective F statistic [1], which is recommended by the review paper by Andrews, Stock, and Sun [2] manually for now using the simplified formula
image

from the Andrews et al paper (the original paper is written in archaic notation with y and Y as the outcome and treatment respectively; ew).
Pretty straightforward to implement / I can send a pull request with the implementation if you think there's enough interest.

happy to move to related F-stat thread if preferred #117

[1] http://www.joseluismontielolea.com/Montiel-OleaJBES.pdf
[2] https://scholar.harvard.edu/files/wirev_092218-_corrected_0.pdf

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions