install.packages("plm") #https://cran.r-project.org/web/packages/plm/vignettes/plmPackage.html library(plm) ## R da bulunan panel veri setleri data("EmplUK", package="plm") data("Produc", package="plm") data("Grunfeld", package="plm") data("Wages", package="plm") str(EmplUK) str(Produc) str(Grunfeld) head(Grunfeld) tail(Grunfeld) E <- pdata.frame(EmplUK, index=c("firm","year"), drop.index=TRUE, row.names=TRUE) head(E) head(attr(E, "index")) summary(E$emp) head(as.matrix(E$emp)) head(lag(E$emp, 0:2)) head(diff(E$emp), 10) head(lag(E$emp, 2), 10) head(Within(E$emp)) head(between(E$emp), 4) head(Between(E$emp), 10) #Several models can be estimated with plm by filling the model argument: #the fixed effects model ("within"), #the pooling model ("pooling"), #the first-difference model ("fd"), #the between model ("between"), #the error components model ("random"). emp ~ wage + capital | lag(wage,1) + capital emp ~ wage + capital | . -wage + lag(wage,1) grun.fe <- plm(inv~value+capital, data = Grunfeld, model = "within") grun.re <- plm(inv~value+capital, data = Grunfeld, model = "random") summary(grun.re) fixef(grun.fe, type = "dmean") summary(fixef(grun.fe, type = "dmean")) ?plm grun.twfe <- plm(inv~value+capital, data=Grunfeld, model="within", effect="twoways") fixef(grun.twfe, effect="time") grun.amem <- plm(inv~value+capital, data=Grunfeld, model="random", random.method="amemiya") ercomp(inv~value+capital, data=Grunfeld, method = "amemiya", effect = "twoways") grun.tways <- plm(inv~value+capital, data = Grunfeld, effect = "twoways", model = "random", random.method = "amemiya") summary(grun.tways) data("Hedonic", package = "plm") Hed <- plm(mv~crim+zn+indus+chas+nox+rm+age+dis+rad+tax+ptratio+blacks+lstat, data = Hedonic, model = "random", index = "townid") summary(Hed) gw <- plm(inv~value+capital, data=Grunfeld, model="within") gr <- plm(inv~value+capital, data=Grunfeld, model="random") phtest(gw, gr) pwtest(log(gsp)~log(pcap)+log(pc)+log(emp)+unemp, data=Produc) pcdtest(inv~value+capital, data=Grunfeld) pcdtest(inv~value+capital, data=Grunfeld, model="within")