Skip to content

Dependent variable is a constant error, when it is not.  #84

@perodmar

Description

@perodmar

First, thank you for the great work with the package and adopting feols. Really useful!

I am trying to use the bacon function but I keep getting the error that the dependent variable is a constant, when it is not:

bacon(n_tot ~ tt,  data = panel[panel$random==1,],
+             id_var = "id_grid", 
+             time_var = "period",
+             quietly = TRUE)

Error in fixest::feols(outcome ~ treated | time + id, data = data1) : 
The dependent variable is a constant. The estimation with fixed-effects cannot be done.

I assume it has to do with the fact that I have lots of zeros, but around 5% are non-zeros:

quantile(panel[panel$random==1,]$n_tot,seq(0.95,1,0.01))
      95%       96%       97%       98%       99%      100% 
0.0000000 0.9677419 0.9677419 1.0000000 1.0714286 8.7096774 

It seems to be a bacon function error since it runs smoothly when I use feols directly:

feols(as.formula("n_tot ~ tt | id_grid + period"), data=panel[panel$random==1,])
OLS estimation, Dep. Var.: n_tot
Observations: 457,125 
Fixed-effects: id_grid: 6,625,  period: 69
Standard-errors: Clustered (id_grid) 
    Estimate Std. Error  t value Pr(>|t|) 
tt -0.003755   0.002513 -1.49411  0.13519 
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
RMSE: 0.250655     Adj. R2: 0.20454 
                 Within R2: 1.141e-5

  1. Is there a way to feed the feols result directly into the bacon function?
  2. Why does that error keep coming up? How to handle it?

Thank you!

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