Petr
Petr

Reputation: 1827

Using broom::augment Panel data models

I would like to ask,

There is a issue when using augment function in panel data, especially on first-differences estimator.

Is there a way how to get using function augment or any approach as well how to retrive regression table even for first-difference estimator? Works perfectly fine for other methods.

library(foreign)
library(plm)

crime <- read.dta("http://fmwww.bc.edu/ec-p/data/wooldridge/crime4.dta")

crime.p <- pdata.frame(crime,index=c("county","year"))

panel1 <- plm(log(crmrte) ~ polpc + prbconv + avgsen + density, data = crime.p, model = "within")
panel2 <- plm(log(crmrte) ~ polpc + prbconv + avgsen + density, data = crime.p, model = "random")
panel3 <- plm(log(crmrte) ~ polpc + prbconv + avgsen + density, data = crime.p, model = "fd")


broom::augment(panel1)
broom::augment(panel2)
broom::augment(panel3)

Upvotes: 1

Views: 90

Answers (1)

Jakub.Novotny
Jakub.Novotny

Reputation: 3047

You can access the components of what the broom::augment function produces manually. The code below might give you some guidance. I first access the model as part of panel3 list and then join the residuals by name. In some instances, the residuals are missing which I suspect is the reason why broom::augment seems not to be working.

data.frame("rownames" = row.names(panel3$model), panel3$model) %>%
      left_join(data.frame("rownames" = names(panel3$residuals), "resid" = panel3$residuals))

Upvotes: 1

Related Questions