crosshyou

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

OECD Trust in government data analysis 6 - Multiple linear regression using R - log(per capita GDP) and inflation rate and iso.

f:id:cross_hyou:20211121164842j:plain

Photo by Jim Cooke on Unsplash 

www.crosshyou.info

This post is following of the above post.

So far previous posts, GDP nor per capita GDP cannot explain Trust in governmnet very well. I will add more variables.

I have CPI, inflation data like below.

f:id:cross_hyou:20211121165200p:plain

I got this data from OECD web site. cpi means infration rate.

Let's add this data.

Firstly, I use read_csv() fundtion to read the data.

f:id:cross_hyou:20211121165540p:plain

I use inner_join() function to merge dataframe "df" and dataframe "oecd_cpi".

f:id:cross_hyou:20211121165826p:plain

Let's see correlation with trust, l_gdp, l_capi and cpi

f:id:cross_hyou:20211121170152p:plain

l_capi and cpi has -0.61 correlation. and it is the absolutely largest correlation.

Let's see scatter plots matrix.

f:id:cross_hyou:20211121170650p:plain

Les's make a liear regression model. In this time, I select l_capi, cpi and iso for variables.

f:id:cross_hyou:20211121171653p:plain

I see l_capi's coefficient is 6.3099 with p-value 0.093. So, l_capi is statistically significant at 10% level. If cpi(infration rate) is fixed, more l_capi(log(per capita GDP)) makes more trust in government. It is natual.

I see some iso(country) has significant coefficients. Let's see it.

f:id:cross_hyou:20211121172628p:plain

ITA, LTU, KOR and POL have statistically low Trust in government if l_capi and cpi are fixed.

RUS, SWE, DNK, CAN and ZAF have statistically high Trus in government if l_capi and cpi are fixed.

That's it. Thank you!

Next post is

 

www.crosshyou.info

 

To read the 1st post,

 

www.crosshyou.info