Description Usage Arguments Details Value Note Author(s) Examples
plm2lm, converts the a plm
object to an lm
object.
The information saved in a plm
object is used to obtain an transformed dataset
(e.g. time-demeaned or first differences)
in order to restimate an OLS model with lm
.
1 | plm2lm(estimate, reestimate = T)
|
estimate |
an object of class |
reestimate |
logical, if TRUE the panel data model is reestimated with a linear regression ( |
estimate - The plm
object estimated by one of the methods within
, fd
.
reestimate - If FALSE, an error displays - A conversion without reestimation is currently not implmented.
A matrix containing the covariance matrix estimate
Reestimation of results leads to an increase in processing requairemets.
ElĂas Cisneros <ec@elias-cisneros.de>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | ##packages
library(foreign)
library(clubTamal)
library(lmtest)
library(plm)
library(clubSandwich)
library(spd4testing)
library(multiwayvcov)
##data
d<-spd4testing()
d
##formula
f<- formula(y ~ x + factor(year))
##standard estimation
e<-plm(formula=f,data=d,model="fd")
summary(e)
## Not run:
# e<-plm(formula=f,data=d,model="within")
# summary(e)
## End(Not run)
##clustering
#no clustering
v<-e$vcov
coeftest(e)
#clustering at id level with plm-package
v<-vcovHC(e,type="HC1",cluster="group",tol=1*10^-20 )
coeftest(e,v)
##clustering at group level with clubSandwich-package
##only for Fixed Effects regressions
v<-vcovCR(e,d$gid,type="CR1")
coef_test(e,vcov=v,test="naive-t")
coeftest(e,v)
##clustering at group level with clubTamal
v<-vcovTamal(estimate=e,data=d,groupvar="gid")
coeftest(e,v)
##clustering with clubTamal but without using the multivcov package
## Not run:
v<-vcovTamal(estimate=e,data=d,groupvar="gid",byhand=T)
coeftest(e,v)
## End(Not run)
##clustering at group level with STATA (TM)
#export data
tdir<-tempdir()
write.csv(d,file.path(tdir,"spd.csv"))
#write stata file
sink(file.path(tdir,"clusterStata.do"))
cat(paste0('insheet using "',file.path("spd.csv"),'", clear'))
cat("\n")
cat('xtset id year')
cat("\n")
cat('xtreg y x i.year, fe')
cat("\n")
cat('xtreg y x i.year, fe vce(cluster gid)')
cat("\n")
cat('reg d.y d.x i.year')
cat("\n")
cat('reg d.y d.x i.year, vce(cluster gid)')
sink()
## RUN Stata file
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.