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

Issue with Inf in iplot #512

Open
kylebutts opened this issue Jun 21, 2024 · 1 comment
Open

Issue with Inf in iplot #512

kylebutts opened this issue Jun 21, 2024 · 1 comment

Comments

@kylebutts
Copy link
Contributor

kylebutts commented Jun 21, 2024

This code (correctly) will not plot because one of the values of x2 is Inf which does not work with xlim (plot.window(...) : need finite 'xlim' values).

This comes up for me when creating a event-study dummies (E.g. never_treated has year_treated = Inf; rel_year = year - year_treated = -Inf).

I'm raising this as an issue b/c I don't know what the best fix would be on fixest's end.

Two user-land fixes could be:

  1. manually change the value from -Inf to -100 or something, but this would make the figure look weird. So, user would have to chose like min - 1 or something which is a pain.
  2. Use drop = "Inf". This is probably the best answer, but the docs do not mention for iplot the values not the normal x2::Inf" regex. As an aside, could we add the error note to the documentation? "Note that in iplot, the variables names are the values that should be in the x-axis."
library(fixest)
data <- data.frame(x1 = runif(100),  x2 = sample(c(1, 2, Inf), 100, replace = TRUE))
data$y <- data$x1 * 2 + rnorm(100)

est = feols(y ~ x1 + i(x2, ref = Inf), data = data)
iplot(est)
#> Error in plot.window(...): need finite 'xlim' values
@lrberge
Copy link
Owner

lrberge commented Jun 24, 2024

Hi Kyle: IYO what should be the expected output?

  • that there is no reference?
  • that Inf is treated as a categorical variable?

I agree with the other points: the doc isn't clear + the error message is arcane.

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