2

I am working with bank-firm level lending panel data (i.e. loans from a group of banks to a group of firms for a country are recorded at a monthly frequency). I want to conduct panel data FE regression. However, to conduct FE, it is required that I set the data as panel data on R using using the plm package:

plm.data(data table name, index=("unique ID","time"))

Is it possible to enter multiple fields in the ID to create a pair-wise identification at a monthly level? (index=("firm ID" "bank ID","time"))

Or do I have to concatenate the firm and bank IDs to make a unique monthly ID variable?

Thank you for your responses. (I cannot attach the data or the code/photo since it is on a remote computer)

Helix123
  • 3,502
  • 2
  • 16
  • 36

2 Answers2

0

One solution to this is to create a group index in your dataframe to capture the panel-groups and use this as the index for the model.

library(dplyr)

data$panel_id <- data %>% group_indicies(firm_id, bank_id, time)

plm.data(data_table_name, index=("panel_id"))

*note I have tidied your variable names in this example, generally speaking you should avoid spaces in variable names.

conor
  • 1,267
  • 10
  • 7
  • Conor, thank you for your response. I am working with data.table format and not dataframe (sorry for not specifying earlier). Is it necessary to create a new column with the panel_ID (since both bank and firm IDs are long string values, and I already have a data table with around 16 million observations and with 40+ variables)? – Pranav Garg Apr 05 '18 at 14:11
0

I found the package lfe which has the command felm that permits multiple FE as well as clustering errors.

library(lfe)
model<-felm(y~x1+x2+x3|firm_id+bank_id+bank_id+time:bank_id|0|bank_id,data=data.table)

This has solved my problem by allowing me to include multiple FEs.

Thank you, Pranav