1

I am looking for a code to estimate the following equation as OLS with panal data:

∆Yjt = α∆Xjt + τt + ujt

where ∆ is the change of Y and X over time, j a sector, t the time, τ a set of time dummies and u the error term.

I'm a beginner in R programming and unfortunately I can't find the appropriate code to take into account ∆.

Does anyone have an idea how I could run the regression?

Thanks for your time and help

lisa-marie
  • 54
  • 4
  • Probably better to also ask this question on cross validate, please provide some data – Bruno Dec 30 '19 at 13:56
  • My understanding is that by logging both the Y ans x variables you could reach this equation but I am not sure about that – Bruno Dec 30 '19 at 13:57
  • 2
    If you search for the `plm` package, and then look into a "first difference" model, you should be able to find how to do this. Or your can repost the question with data and references to plm and first difference. – Jeremy K. Dec 30 '19 at 14:04

2 Answers2

0

Welcome, lisa-marie. As Jeremy pointed out, try plm. It provides some sample data. I assume that "OLS with panel data" implies a pooled regression? Compare it to a fixed effects regression:

library("plm")
data("Produc", package = "plm")

# Pooled Regression    
pooled <- plm(log(gsp) ~ log(pcap) + log(pc) + log(emp) + unemp,
          data = Produc, 
          index = c("state","year"),
          method="pooling")

# Fixed Effects Regression    
fe <- plm(log(gsp) ~ log(pcap) + log(pc) + log(emp) + unemp,
          data = Produc, 
          index = c("state","year"),
          method="within")

Best regards

Marco
  • 2,368
  • 6
  • 22
  • 48
0

My solution for the problem was finally: I calculated changes ∆ with tidyverse and was able to solve the problem easily.

Marco's solution with log would have been even easier, but because I had to deal with negative values I could not use it.

Thanks everyone for your help!

lisa-marie
  • 54
  • 4