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 :
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)
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")