You are on page 1of 2

07/06/2023, 13:32 regression - Is there a way to both include PCSE and Prais-Winsten correction in a fixed effects model in R (similar

(similar to the xt…

As of May 31, 2023, we have updated our Code of Conduct.

Is there a way to both include PCSE and Prais-Winsten correction in


a fixed effects model in R (similar to the xtpcse function in Stata)?
Asked 4 years, 1 month ago Modified 2 years, 10 months ago Viewed 1k times
Part of R Language Collective

I want to estimate a fixed effects model while using panel-corrected standard errors as well as
Prais-Winsten (AR1) transformation in order to solve panel heteroscedasticity,
1 contemporaneous spatial correlation and autocorrelation.

I have time-series cross-section data and want to perform regression analysis. I was able to
estimate a fixed effects model, panel corrected standard errors and Prais-winsten estimates
individually. And I was able to include panel corrected standard errors in a fixed effects
model. But I want them all at once.

# Basic ols model


ols1 <- lm(y ~ x1 + x2, data = data)
summary(ols1)

# Fixed effects model


library('plm')
plm1 <- plm(y ~ x1 + x2, data = data, model = 'within')
summary(plm1)

# Panel Corrected Standard Errors


library(pcse)
lm.pcse1 <- pcse(ols1, groupN = Country, groupT = Time)
summary(lm.pcse1)

# Prais-Winsten estimates
library(prais)
prais1 <- prais_winsten(y ~ x1 + x2, data = data)
summary(prais1)

# Combination of Fixed effects and Panel Corrected Standard Errors


ols.fe <- lm(y ~ x1 + x2 + factor(Country) - 1, data = data)
pcse.fe <- pcse(ols.fe, groupN = Country, groupT = Time)
summary(pcse.fe)

In the Stata command: xtpcse it is possible to include both panel corrected standard errors
and Prais-Winsten corrected estimates, with something allong the following code:

xtpcse y x x x i.cc, c(ar1)

I would like to achieve this in R as well.

r regression plm economics autocorrelation


Join Stack Overflow to find the best answer to your technical question, help others
Sign up
answer theirs.

https://stackoverflow.com/questions/56042590/is-there-a-way-to-both-include-pcse-and-prais-winsten-correction-in-a-fixed-effe 1/2
07/06/2023, 13:32 regression - Is there a way to both include PCSE and Prais-Winsten correction in a fixed effects model in R (similar to the xt…

Share Follow edited May 13, 2019 at 9:53 asked May 8, 2019 at 14:00
Helix123 Bo Boaz Kaarsemaker
3,422 2 16 35 Kaars 61 7

Sorted by:
1 Answer
Highest score (default)

I am not sure that my answer will completely address your concern, these days I've been
trying to deal with the same problem that you mention.
0
In my case, I ran the Prais-Winsten function from the package prais where I included my
model with the fixed effects. Afterwards, I correct for heteroskedasticity using the function
vcovHC.prais which is analogous to vcovHC function from the package sandwich.

This basically will give you White's/sandwich heteroskedasticity-consistent covariance matrix


which, if you later fit into the function coeftest from the package lmtest, it will give you the
table output with the corrected standard errors. Taking your posted example, see below the
code that I have used:

# Prais-Winsten estimates with Fixed Effects


library(prais)
prais.fe <- prais_winsten(y ~ x1 + x2 + factor(Country), data = data)

library(lmtest)
prais.fe.w <- coeftest(prais.fe, vcov = vcovHC.prais(prais.fe, "HC1")

h.m1 # run the object to see the output with the corrected standard errors.

Alas, I am aware that the sandwhich heteroskedasticity-consistent standard errors are not
exactly the same as the Beck and Katz's PCSEs because PCSE deals with panel
heteroskedasticity while sandwhich SEs addresses overall heteroskedasticity. I am not totally
sure in how much these two differ in practice, but something is something.

I hope my answer was somehow helpful, this is actually my very first answer :D

Share Follow answered Aug 6, 2020 at 0:18


Ramskin
1

Join Stack Overflow to find the best answer to your technical question, help others
Sign up
answer theirs.

https://stackoverflow.com/questions/56042590/is-there-a-way-to-both-include-pcse-and-prais-winsten-correction-in-a-fixed-effe 2/2

You might also like