crosshyou

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

OECD Doctors' consultations data analysis 6 - using lm() function for linear regression

f:id:cross_hyou:20210613083954j:plain

 Photo by DAVID TANG on Unsplash  

www.crosshyou.info

 This post is following of above post.

In this blog, I will do regression anaysis using lm() function in R.

Let's go ahead.

f:id:cross_hyou:20210613084339p:plain

summary() function displays result.

f:id:cross_hyou:20210613084458p:plain

p-value is 0.4024, it is greater than 0.05, so this model is not valid model.

Let's add 'region' to explanatory variable.

f:id:cross_hyou:20210613084755p:plain

p-value is 0.3377.

Let's add quadratic of pct_chg

f:id:cross_hyou:20210613085122p:plain

p-value is 0.2579, it is not valid.

Uhmm.... let's add Y2007^3 , Y2007^4 and Y2007^5.

f:id:cross_hyou:20210613085602p:plain

p-value is o.02613, it is smaller than 0.05. 

Let's plot scatther plot of Y2007 and pct_chg and add predicted values.

First, makeing plot

f:id:cross_hyou:20210613090118p:plain

f:id:cross_hyou:20210613090132p:plain

next, adding predicted values.

f:id:cross_hyou:20210613090548p:plain

f:id:cross_hyou:20210613090600p:plain

red + is predicted value by lm_model4.

That's it. Thank you!

 

To read the 1st post...

 

www.crosshyou.info