I try to run a panel regression. I'm working with plm packages and I have problems with within and random. I always get "Error in plm.fit(data, model = models[1], effect = effect) : empty model" when I use the within model. It's the same with random but when I choose "walhus" as random method it works. I'm new in panel regressions and I'm confused what's wrong. Here is my script:
# install.packages("plm")
library(ggplot2)
library(plm)
data <- read.csv('Data.csv', header=TRUE, stringsAsFactors=F)
attach(data)
panel_data <- plm::pdata.frame(data, index = c("id", "year"))
between <- plm(length ~ location, data=panel_data, model="between")
summary(between)
pooling <- plm(length ~ location, data=panel_data, model="pooling")
summary(pooling)
firstdiff <- plm(length ~ location, data=panel_data, model="fd")
summary(firstdiff)
within <- plm(length ~ location, data=panel_data, model="within")
summary(within)
random1 <- plm(length ~ location, data=panel_data, model="random")
random2 <- plm(length ~ location, data=panel_data, model="random", random.method = "walhus")
summary(random1)
summary(random2)`
Can anyone help me? Here are the data: https://docs.google.com/spreadsheets/d/14qKoJyVrATPnj5cxtByfU4zyt5-tdAcQJLPBhvZ7cPc/edit?usp=sharing
Thanks
Aucun commentaire:
Enregistrer un commentaire