Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in esttex() when p-value < 2.2e-16 #504

Closed
MaelAstruc opened this issue Jun 4, 2024 · 1 comment
Closed

Bug in esttex() when p-value < 2.2e-16 #504

MaelAstruc opened this issue Jun 4, 2024 · 1 comment

Comments

@MaelAstruc
Copy link
Contributor

Hello,

I have an issue with the esttex() function and the fit statistics of an IV. More precisely, when I want to include a Wu-Hausman endogeneity test using fitstat = "wh.p", it prints $NaN\times 10^{-Inf}$.

I looked a bit into it and the issue seems to come from the formatting of the results when the p-value is too small. Here is a reproducible example:

# Here is what I have
y <- fixest::fitstat(results,  "wh.p", etable = TRUE, verbose = FALSE)
str(y)
# List of 1
#  $ wh.p: num 0

# You can start from here
y <- list(wh.p = 0)

fixest:::format_number(y)
#       wh.p 
# "NaNe-Inf" 

# To mimic the sapply function in format_number()
x <- unlist(y)

fixest:::format_nber_single(x, digits = 2)
# [1] "NaNe-Inf"

# The culprit is line 19 of format_nber_single()
floor(log10(abs(x)))
# wh.p 
# -Inf 

I think there should be a check to handle the case where x == 0, maybe after the checks at the beginning of the function. Regarding the formatting:

  • it could always be '0'
  • it could be either '0' or '< 2.2e-16' depending on the name of the type of fit statistics, checking that it ends with ".p"

If I understood the issue correctly and one of the solutions sounds good to you, I can write a short PR.

@lrberge
Copy link
Owner

lrberge commented Jun 11, 2024

Thanks for the report, now fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants