Reputation: 1
I want to do panel regression R and use multiple fixed effects. I am trying to construct panel dataset first by using pdata.frame function, but I am not sure whether I am doing it right.
I have trade transaction data ranging from 2010 to 2015 and that data shows firms exporting to certain destinations. That being said, there are multiple firms exporting, and obviously to different destinations at the same time. Thus, rows would look like,
firm. destination year
Firm A US. 2010. ...
Firm A. Mexico. 2010
Firm B. Russia. 2010
Firm C. China. 2011
like this.
I tried to use pdata.frame function to make dataset to panel dataset. I know that in order to be a panel dataset, it needs individual and time index.
However, since same firm name are appearing in multiple rows(firms which are exporting to the same destination at the same year), I could not select firm as an index. How can I make panel data set to perform regression using plm?
What I did was combining firm and destination column, and make panel dataset based on that. Therefore the panel dataset would look like,
identifier. firm. destination. year
Firm A * US * 2010 firm A. US. 2010
Firm A * Mexico * 2010 firm A. Mexico. 2010
...
like this. Is this the right way to construct panel dataset using pdata.frame?
After doing that, I made plm regression as follows.
model <- plm(dependent ~ regressor, index = "firm", data = panel_data, model = "within")
However, result I got was exactly same as the results from,
model <- plm(dependent ~ regressor, data = panel_data, model = "within").
which implies firm-fixed effect had no effect at all.
I was doubtful with this result and guess maybe data construction itself was wrong.
Upvotes: 0
Views: 154
Reputation: 3687
Very likely, you estimated the same model with both commands. This is not so much a programming or plm question but rather a conceptional question about panel data dimensions.
With the index argument of plm's pdata.frame (or in function plm directly), you do not specify the fixed effects. You specify the panel structure of the data, i.e., which variable serves as observational unit ("individual") and which variable specifis the time slices ("time"), so two dimensions. If you specify only the first dimension, the time dimension is generated and likely not what you want in this case. You want the year
variable to serve as the 2nd index.
For the first, dimension: As you have the same firm multiple times for a year, the data is conceptually not readily applicable for a fixed effects model. You either want to aggregate the values to derive a measure per firm-year combination (e.g., average of firm-year combination) or view the combination of firm-destination as your observational unit (thus not firm only as observational unit). For the latter approach would combine firm and destination in a variable (e.g. by concatenating the two strings). Be aware that your "individual" effect then is not a firm fixed effect but the firm-destination fixed effect.
In plm
, argument effect
set to "individual"
will estimate a one-way model with the effect specified as the first panel data dimension (so either firm or firm-destination here).
Upvotes: 1