I'm not 100% sure this is a coding issue, let me know.
I'm trying to plot the coefficients of this DiD model using fake data, but I'm not savvy enough to know if it's a problem coefplot() or if it's that my model, feols(...), is misspecified.
Any ideas?
EDIT: I did notice just now that the y values are NaN in feols(...) call, maybe that is the issue? The estimates seem good, so I'm still not sure what this implies.
library(fixest)library(dplyr)# Create fake datafake_data <- tibble( state = c(rep("c",10), rep("t",10)), time = c(1:10,1:10), treat = c(rep(0,15), 1,1,1,1,1), y = c(seq(9,36,3), seq(11,23,3), 28,31,34,37,40) ) |> mutate(state = factor(state, levels = c("t","c"))) |> mutate(y = c(seq(9,36,3), seq(11,23,3), 28,31+2,34+4,37+6,40+8))
Data looks like:
# A tibble: 20 × 4 state time treat y<fct> <int> <dbl> <dbl> 1 c 1 0 9 2 c 2 0 12 3 c 3 0 15 4 c 4 0 18 5 c 5 0 21 6 c 6 0 24 7 c 7 0 27 8 c 8 0 30 9 c 9 0 3310 c 10 0 3611 t 1 0 1112 t 2 0 1413 t 3 0 1714 t 4 0 2015 t 5 0 2316 t 6 1 2817 t 7 1 3318 t 8 1 3819 t 9 1 4320 t 10 1 48
Model seems to work:
feols(y ~ i(time, state, ref = 5) | state + time, data = data_mult_t_dyn) |> etable(vcov = "iid") feols(y ~ i(t..Dependent Var.: ytime = 1 x state = t -1.95e-14 (NaN)time = 2 x state = t -1.33e-14 (NaN)time = 3 x state = t -1.6e-14 (NaN)time = 4 x state = t -1.6e-14 (NaN)time = 6 x state = t 2.000 (NaN)time = 7 x state = t 4.000 (NaN)time = 8 x state = t 6.000 (NaN)time = 9 x state = t 8.000 (NaN)time = 10 x state = t 10.00 (NaN)Fixed-Effects: ---------------state Yestime Yes_____________________ _______________S.E. type NA (not-avail.)Observations 20R2 1Within R2 1---Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 '' 1
I can't plot the coefficients:
test <- feols(y ~ i(time, state, ref = 5) | state + time, data = data_mult_t_dyn) coefplot(summary(test))coefplot(test)
Output:
Error in plot.window(...) : need finite 'ylim' values