crosshyou

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

OECD Material productivity data analysis 6 - Using R to analyze panel data with plm package

f:id:cross_hyou:20220227144902j:plain

Photo by JD Rincs on Unsplash 

www.crosshyou.info

This post follows above post.
In this post, I will do panel data regression analysis with R using plm package.

First, le's see which year has many observations.

f:id:cross_hyou:20220227145405p:plain

2010, 2011, 2012, 2013 and 2014 have 57 observations. I use 2010 and 2014 data for panel data analysys.

I load plm package first.

f:id:cross_hyou:20220227145556p:plain

I use panel dataframe with pdata.frame function

f:id:cross_hyou:20220227145907p:plain

pdim() functions shows panel dataframe structure. We see our panel dataframe is balanced panel data, n = 57, T = 2, N = 57*2 = 114.

I will make dummy variable if TIME = 2010, 1 otherwise = 0

f:id:cross_hyou:20220227151207p:plain

Then, let's begin with pooled cross section model.

f:id:cross_hyou:20220227151533p:plain

We see r_capi has 0.02 coefficient and strongly significent.

Next, we do First Differenced Estimator.

I have underluing model in mind, which model is following.

y_it = beta_0 + beta_1*d2010 + beta_2*r_capi_it + a_i + u_it

i indicates each LOCATION, t indicates TIME, 2010 or 2014. a_i is unobserved effect, which is the same in 2010 and in 2014(so, there is not 't').
So, for 2010,

NONNRGMAT_i2010 = beta_0 + beta_1*d2010 + beta_2*r_capi_i2010 + a_i + u_i2010 >>> formula_2010

For 2014,

NONNRGMAT_i2014 = beta_0 + beta_2*r_capi_i2014 + a_i + u_i2014. >>> formula_2014

formula_2014 - formula_2010 =

NONNRGMAT_i2014 - NONNRGMAT_i2010 = ΔNONNRGMAT_i = -beta_1 + beta_2*Δr_capi_i + Δu_i >>> formula_fd

In formula_fd, there is not unobserved effect, a_i.

We can do above estimate with plm() function with model = "fd".

f:id:cross_hyou:20220227154743p:plain

r_capi coeeficient turns into negative, -0.022 and it is not significant at 5% level.

model = "within" makes Fixed Effects Estimator, in two time panel data, it is almost the same as FIrst Differenced Estimator. Let's do it.

f:id:cross_hyou:20220227155509p:plain

r_capi coefficient is 0.013 and significant.

model = "random" makes Random Effect Estimator. Ler's fo it.

f:id:cross_hyou:20220227155754p:plain

r_capi coefficient is 0.019 and significant.

Lastly, I use stargazer() function to compare 4 estimator results.

f:id:cross_hyou:20220227160200p:plain

That's it. Thank you!

To read the 1st post,

 

www.crosshyou.info