Rで何かをしたり、読書をするブログ

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

OECD Household disposable income data analysis 5 - simple linear regression analysis using R

f:id:cross_hyou:20210815173548j:plain

 Photo by V Srinivasan on Unsplash  

www.crosshyou.info

 This post is following of the above post.

In this post, let's do simple linaer regression anaysis using R.

First, I use df_country data frame.

f:id:cross_hyou:20210815173941p:plain

Coefficients of avg_gr_us is -1.002e-04, it is -0.000102.

So, if avg_gr_us incleased by 1 unit, avg_ne_ag would decrease by -0.000102. 
it is a bit difficult to understance, so, I will multiply avg_gr_us by 10000.

f:id:cross_hyou:20210815174600p:plain

Now, coefficient of I(avg_gr_us/10000) is -1.0025 with standard error 0.2833.

Dgrees of 35. so 95% confidence interval of I(avg_gr_us) is

f:id:cross_hyou:20210815175534p:plain

-1.58 ~ -0.427

Next, let's use country_year data frame.

f:id:cross_hyou:20210815174735p:plain

Coefficients of I(avg_gr_us/10000) is -0.8626. with standard error 0.1848 and degrees of freedom 49.

So, 95% confidence interval of I(avg_gr_us/10000) is

f:id:cross_hyou:20210815175912p:plain

-1.23 to -0.491. This interval is within -1.58 ~ -0.427.

Next, let's make a schatter plot for these two models.

 

f:id:cross_hyou:20210815180543p:plain

f:id:cross_hyou:20210815180556p:plain

That' it. Thank you!

Next post is

 

www.crosshyou.info

 



To see the 1st post,

 

www.crosshyou.info