1

I am working with panel data using the plmpackage in R and need to specify a state and year fixed effects model with linear state-specific trends. I have the following code so far:

pnl_sb <- pdata.frame(seatbelt.df, index = c("fips","year"))
twyreg <- plm(fatalityrate~sb_useage+primary*sb_useage+secondary*sb_useage+speed65+speed70+ba08+drinkage21+log(income)+age, data = pnl_sb, model = "within", effect = "twoways")

fips is the unit variable states and year is the time variable. I simply do not know how to implement state-specific trends. I thought that it would be assumed with 2 way fixed effects panel data that added year as a time trend. But, I am having some doubts.

Helix123
  • 3,502
  • 2
  • 16
  • 36
Collective Action
  • 7,607
  • 15
  • 45
  • 60

1 Answers1

0
pnl_sb <- pdata.frame(seatbelt.df, index = c("fips","year"))
twyreg <- plm(fatalityrate~factor(state)*year, data = pnl_sb, model = "within", effect = "twoways")

Specifically: factor(state) ensures all of the states will be used. By multiplying this factor(state) by year trends are created for each state.

Collective Action
  • 7,607
  • 15
  • 45
  • 60