crosshyou

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

OECD Material productivity data analysis 4 - Using R for Time-Series Data analysis, static model and finite distributed lag model

f:id:cross_hyou:20220223083554j:plain

Photo by mostafa meraji on Unsplash 

www.crosshyou.info

This post follow abovr post.

In the previous post, I did cross section data analysis. In this post, I do time-series data analysis.

First, let's check how many LOCATION have most data.

f:id:cross_hyou:20220223084056p:plain

ISL, FRA, CHE and BEL have 30 observations. So I will use those locations for time-series data analysis.

I make dataframe for time seriea analysis.

f:id:cross_hyou:20220223084708p:plain

Then, I use ts() function to convert it to ts object.

f:id:cross_hyou:20220223084922p:plain

It is easy to make plots with ts object.

f:id:cross_hyou:20220223085149p:plain

f:id:cross_hyou:20220223085201p:plain

using plot() function with ts object shows line charts for each variables at onece.

We can use diff() function to get difference.

f:id:cross_hyou:20220223085940p:plain

f:id:cross_hyou:20220223085951p:plain

let's see correlations with cor() function.

f:id:cross_hyou:20220223091747p:plain

They are strongly correlated each other.

How about difference correlation?

f:id:cross_hyou:20220223092129p:plain

Then, I do time-series regression. I refer to following books.

 

 

Firstly, I examine static time series models.

nonnrgmat = b0 + b1*gdp + u

Before making regression analysis, let's make a scatter plot.

f:id:cross_hyou:20220223093008p:plain

f:id:cross_hyou:20220223093041p:plain

to do time-series data regression, I use dynlm package's dynlm() function.

f:id:cross_hyou:20220223093356p:plain

Since nonnrgmat and GDP are too different scale, I transform GDP to GDP/1000000.

f:id:cross_hyou:20220223093809p:plain

So, 1 GDP/1e+06(1 million GDP) change makes 1.4897 nonnrgmat change.

Next, I make Finite Distributed Lag model.

f:id:cross_hyou:20220223094247p:plain

All three explanatory variables are not significant on individual base, but I assume they are jointly significant. Let's checl with linearHypothesis() function.

f:id:cross_hyou:20220223094713p:plain

p-value is almost 0. So, I confirm that the three explanatory variables are jointly significant.
It's long run propency is -0.8012 + 0.5368 + 2.0429 = 1.7785.

That's it. Thank you!

The next post is

 

www.crosshyou.info

 


To see the first post,

 

www.crosshyou.info