crosshyou

主にクロス表(分割表)分析をしようかなと思いはじめましたが、あまりクロス表の分析はできず。R言語の練習ブログになっています。

OECD Material Productivity data analysis 5 - Using R for testing AR(1) serial correlation.

f:id:cross_hyou:20220226113302j:plain

Photo by Ken Cheung on Unsplash 

www.crosshyou.info

This post follows above post. 
I add trend variable to static model.

f:id:cross_hyou:20220226145926p:plain

Althogh adding trend, GDP is still significant.

So, I make three model, static model, finite distributed lag model and static + trend model.
Let's check if there is serial correlation in those models.

Firstly, let's make graphs for residuals.

f:id:cross_hyou:20220226150728p:plain

f:id:cross_hyou:20220226150738p:plain

All three residuals are very similar and it seems there is serial correlation.

Let's test with dynlm() function and coeftest() fundtion.

f:id:cross_hyou:20220226151456p:plain

static_model and fdl_model have p-value less than 0.01, so the both model have AR(1) serial correlation. static + trend model p-value is 0.1159, so it seems that static + trend model does not have serial correlation.

Next, let's test if there is AR(2) serial correlation in static + trend model.

f:id:cross_hyou:20220226152940p:plain

first lag has very small p-value, 0.06515, but it is still grater than 0.05. I don't reject null hypothese:there is not serial correlation at 5% significant level.

Finally, let's plot actual nonnrgmat and static + trend model predict value.

f:id:cross_hyou:20220226152258p:plain

f:id:cross_hyou:20220226152308p:plain

That's it. Thank you!

The next post is

 

www.crosshyou.info

 

For the 1st post,

 

www.crosshyou.info