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.
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 usingfitstat = "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:
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:If I understood the issue correctly and one of the solutions sounds good to you, I can write a short PR.