2
$\begingroup$

I am trying to replicate the following econometric equation from the paper "How do french manufacturing firms react to Energy shocks ?" enter image description here

s denotes sectors,i denotes firms, and t denotes year. The paper uses panel data. As you see it has $\phi_i$ for firms fixed effects. I know how to implement such in R, I would use the following code:

model1 <- plm(log(Panel$Prices)~ log(Panel$Electricity.pricr)+log(Panel$Gaz.Price)+
          data=Panel, index= c("Secteur","Date"), model="within",effect= "individual")

The command effect= "individual" enables me to have firm fixed effect.

However the paper includes also sector-year fixed effects $\chi_{st}$. But I do not know how to implement a fixed effect that plays on two variable at the same time: s and t. Do you know how I could implement it in R ?

Thank you

$\endgroup$
5
  • $\begingroup$ interaction(secteur, year) seems to do the job. It generates a factor. You can add it as a regressor. $\endgroup$
    – user18214
    Commented Mar 31, 2023 at 15:14
  • $\begingroup$ Thank you, but how would you write that piece of code ? $\endgroup$
    – BAL
    Commented Mar 31, 2023 at 16:02
  • $\begingroup$ model1 <- plm(log(Panel$Prices)~ log(Panel$Electricity.pricr)+log(Panel$Gaz.Price)+ interaction(Secteur, year), data=Panel, index= c("Secteur","Date"), model="within",effect= "individual") $\endgroup$
    – user18214
    Commented Apr 2, 2023 at 11:20
  • $\begingroup$ Assuming you have a year variable $\endgroup$
    – user18214
    Commented Apr 2, 2023 at 11:20
  • $\begingroup$ Do you have a complete reference of the paper (maybe a link)? It is not possible to find it easily. $\endgroup$
    – Bertrand
    Commented May 1, 2023 at 13:23

1 Answer 1

1
$\begingroup$

Here is a sketch of the code:

  1. Concatenate the sector and year, so it reads as "energy1987" or so. They should be unique.
  2. Encode this concatenated vector as a collection of binary dummies.
  3. Use this set of dummies in the regression.

But given a choice about reinventing the wheel, use the existing tools.

$\endgroup$
1
  • $\begingroup$ Would it work just by adding +Panel$Date * Panel$Secteur in the regressor like this ? : plm(log(Panel$Prices)~ log(Panel$Electricity.price)+log(Panel$Gaz.Price)+ Panel$Date * Panel$Sector, data=Panel, index= c("Sector","Date"), model="within",effect= "individual") $\endgroup$
    – BAL
    Commented Apr 4, 2023 at 14:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.