www.crosshyou.info

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

OECD Road accidents data analysis 5 - Time Series Data Regression using R

f:id:cross_hyou:20210807124418j:plain

Photo by JJ Ying on Unsplash  

www.crosshyou.info

 This post is following of above post.
In this post, I woll do time series data regression using R , dynlm package.

Firstly, I wll make time series data.

f:id:cross_hyou:20210807124710p:plain

 

Then, let's see how data is looking. Let's make a scatter plot.

f:id:cross_hyou:20210807124806p:plain

f:id:cross_hyou:20210807124819p:plain

We see al_acci_nbr and al_death_hab are highly correlated and there seems time trend, the both data are declining year by year.

Next, we make ts object with ts() function

f:id:cross_hyou:20210807125131p:plain

All right, we use dynlm package's dynlm() fundtion for time sereis data regression.

f:id:cross_hyou:20210807125331p:plain

We can add time trend with trend(data).

f:id:cross_hyou:20210807125442p:plain

We see time trend:trend(tsdata) and al_acci_nbr are both statistically significant under 1% level.

Let's make pretty regreesion table with stargazer package's stargazer() function.

f:id:cross_hyou:20210807125725p:plain

That's it. Thank you!

To read 1st post,

 

www.crosshyou.info