0

I am using following code with panel data. I am able to get the year fixed effect but I am unable to get the bank fixed effect. I am getting the bank effect by using lm but not by plm.

I am sharing the sample data :

sample data

p_data <- pdata.frame(data_1, index = c("id", "time"),drop.index = TRUE)

fixed1 <- plm(y ~ x, data=p_data, model="within")
summary(fixed1)

fixed2 <- plm(y ~ x + factor(year) - 1, data=p_data, model="within")
summary(fixed2)

fixed3 <- plm(y ~ x + factor(bank) - 1, data=p_data, model="within")
summary(fixed3)

fixed4 <- plm(y ~ x + factor(year) + factor(bank) - 1, data = p_data, model="within")
summary(fixed4)
Generous Badger
  • 404
  • 2
  • 10
zeeshan
  • 3
  • 2
  • Please don't post data as images. Take a look at how to make a [great reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) for ways of showing data. – Martin Gal Jul 26 '21 at 23:34

1 Answers1

0

fixed3 already is a bank fixed effects model as the default fixed effects are the individual effects (in your case id eq. to bank; it is just coded differently). Look at these two models for bank fixed effects:

fixed3.1 <- plm(y ~ x + factor(bank) - 1, data=p_data, model="pooling")
summary(fixed3.1)

fixed3.2 <- plm(y ~ x, data=p_data, model="within")
summary(fixed3.2)
fixef(fixed3.2)

For a two-ways model, look at:

fixed4.tw <- plm(y ~ x, data = p_data, model="within", effect = "twoways")
summary(fixed4.tw)
fixef(fixed4.tw)
fixef(fixed4.tw, effect = "time")
fixef(fixed4.tw, effect = "twoways")
Helix123
  • 3,502
  • 2
  • 16
  • 36
  • I am not getting the effects of individual banks in fixed4.tw like it is displaying in fixed3.1. like this: Estimate Std. Error t-value Pr(>|t|) x -2.6330 1.2434 -2.1175 0.0346349 * factor(bank)ALD 125.6838 62.3488 2.0158 0.0442727 * factor(bank)ANDH 128.2210 62.3488 2.0565 0.0401734 * factor(bank)AXIS 210.9056 62.7811 3.3594 0.0008317 *** factor(bank)BNDH 142.8851 73.7119 1.9384 0.0530487 . – zeeshan Jul 28 '21 at 16:10
  • fixed4.tw is a twoways model, unlike fixed3.1, which is a one-way model. For twoway models, the effects of the two dimensions will be different compared to the respective one-way effects (not a coding remark though, you might want to read up on the theory of one-way and two-way models). However, looking at the examples in `?plm::fixef` might could be sufficient if you just want some example calculations. – Helix123 Jul 28 '21 at 19:22