crosshyou

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

OECD Business confidence Index(BCI) data analysis 7 - making a panel dataframe using plm packages pdata.frame() function.

f:id:cross_hyou:20211031083523j:plain

Photo by Samuel Mwamburi on Unsplash 

www.crosshyou.info

This post is following of above post.

I have GDP and per capita GDP data file like below.

f:id:cross_hyou:20211031083819p:plain

Let's use this data too.

I load this data with read_csv() function.

f:id:cross_hyou:20211031090836p:plain

Then, I will merge gdp_data dataframe and df dataframe using inner_join() function.

f:id:cross_hyou:20211031091216p:plain

Then, I will make a new dataframe grouped by iso and year.

f:id:cross_hyou:20211031092116p:plain

Then, I will convert df2 to panel dataframe.

I load plm package.

f:id:cross_hyou:20211031092341p:plain

Then, I use pdata.frame() function.

f:id:cross_hyou:20211031092609p:plain

pdim() function shows df2 dimension.

f:id:cross_hyou:20211031092801p:plain

df2 is unbalanced panel data, there is 43 countries and minimum years is 11 and maximum years is 55. 

I add gdp growth rate and capi growth rate, I use difference of logarithm.

f:id:cross_hyou:20211031093715p:plain

Let's confirm it worked fine.

f:id:cross_hyou:20211031093945p:plain

AUS-1967 gdp is 41004.02 and AUS-1966 gdp is 38385.31, so log(41004.02) - log(38285.31) = 0.6860, it is the same as AUS-1967 g_gdp.

I use na.omit() function to delete NA rows.

f:id:cross_hyou:20211031094238p:plain

Let' see summary of df2.

f:id:cross_hyou:20211031094419p:plain

That's it. Thank you!

Next post is

 

www.crosshyou.info

 

 

To read from the first post,

 

www.crosshyou.info