www.crosshyou.info

政府統計の総合窓口のデータや、OECDやUCIやのデータを使って、Rの練習をしています。ときどき、読書記録も載せています。

OECD Gender wage gap data analysis 5 - Serial Correlation Test using R

f:id:cross_hyou:20210904175227j:plain

Photo by BP Miller on Unsplash 

www.crosshyou.info

This post is following of the above psot.

In this post, let's test if there is serial correlation.

Firdt of all, load lmtest package.

f:id:cross_hyou:20210904175406p:plain

All right, let's start with model1.

f:id:cross_hyou:20210904180523p:plain

p-value of lag residual is 0.005491. So, model1 has serial correlation.

 

Let's check model2.

f:id:cross_hyou:20210904180710p:plain

p-value is 0.01021. So, model2 also has serial correlation.

How about model3?

f:id:cross_hyou:20210904182642p:plain

p-value is 0.01234, so model3 also has serial correlation.

We see model1, model2 and model3, all models have serial correlation.

So, let's do serial correlation robust inference.

First, load sandwich package.

f:id:cross_hyou:20210904182917p:plain

model1 serial correlation robust inference.

f:id:cross_hyou:20210904183017p:plain

model2 serial correlation robust inference.

f:id:cross_hyou:20210904183105p:plain

model3 serial correlation robust inference

f:id:cross_hyou:20210904183217p:plain

model3's emp p-value is 0.003413, it is the smallest among model1, model2 and model3.
So, model3 seems the best model

Lastly, let's compare r-squared.

f:id:cross_hyou:20210904183800p:plain

We see model3 has the largest r-squared, 0.236.

That's it. Thank you!

 

To see the 1st post,

 

www.crosshyou.info