www.crosshyou.info

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

OECD Meat Consumption Data Analysis 8 - Serial Correlation Robust Inference using R

f:id:cross_hyou:20210919201421j:plain

Photo by T o T on Unsplash 

www.crosshyou.info

This post is following of above post.

In this post, I will check if there is serial correlation in the previous regression model.

First, I make residual with resid() function.

f:id:cross_hyou:20210919201617p:plain

Then, let's make a graph for the residual.

f:id:cross_hyou:20210919201730p:plain

f:id:cross_hyou:20210919201740p:plain

I cannot tell if there is serial correlation by watching above graph.

Let's check it.

f:id:cross_hyou:20210919201912p:plain

st_residual and L(st_residual) are highly correlated. So, st_model has serial correlation.

So, let's make Serial Correlation Robust Inference with lmtest package and sandwich package.

f:id:cross_hyou:20210919202127p:plain

capi is still statistically significant, t-value is 9.2124.

Let's see usual inference

f:id:cross_hyou:20210919202315p:plain

capi's t-value is 10.859, it is greater than serial correlation robust inference.

That's it. Thank you!

To read the 1st post,

 

www.crosshyou.info