fixest
fixest copied to clipboard
Package won't allow for lagged variables
I am trying to estimate a simple linear model in a panel setting. I would like to use the l()
function provided by fixest
. Here is the example:
library(tidyverse)
library(fixest)
my_data <- read_csv("test_data.csv")
mod1 <- feols(short_disagreement ~ l(leverage, 1),
my_data,
panel.id = c("gvkey", "month"))
mod2 <- feols(short_disagreement ~ lagged_leverage,
my_data |> group_by(gvkey) |> mutate(lagged_leverage = lag(leverage, 1)),
panel.id = c("gvkey", "month"))
The variables gvkey
and month
are track individuals and time in this data. I can estimate mod2
but I can't estimate mod1
. It will throw the following error:
Error in feols(short_disagreement ~ l(leverage, 1), my_data, panel.id = c("gvkey", :
All observations contain NAs. Estimation cannot be done. (Breakup: RHS: 39,803.)
Here is the data in csv format: https://drive.google.com/file/d/1oupZX8iQNQv6_q-2wYlCV-Nax40jAByk/view?usp=sharing
Any ideas on what's happening?