Skip to menu

회귀모형 자동해석

cardiomoon 2020.03.08 22:25 Views : 446

안녕하세요? 문건웅입니다. 이번에 웹R프로그램을 대대적으로 다시 짜고 있습니다. 프로그램을 손보는 김에 우선 회귀모형에 대한 설명을 해주는 함수를 만들어 보았습니다. 제가 영어도 짧고 통계가 전공이 아니어서 오류가 있을까 걱정됩니다. 한번 보시고 평가해주시면 고맙겠습니다. 

Loading the packages

library(webrSub)
library(predict3d)

Simple linear regression

fit=lm(mpg~wt,data=mtcars)
ggPredict(fit)

cat(result=explain(fit))
The predictor variable 'wt' accounts for 75.28 % of the total variation of your dependent variable 'mpg'. Your R^2 is quite good. The coefficient for 'wt' is smaller than zero. This means that the value of your dependent variable 'mpg' decreases by 5.34 for any increase of 1 in your independent variable 'wt'. The coefficient is  significantly different from zero(p< 0.001). The predicted value of dependent variable 'mpg' is calculated by the equation: '37.29 - 5.34*wt'.

Polynomial regression

fit=lm(mpg~wt+I(wt^2),data=mtcars)
ggPredict(fit)

cat(explain(fit))
The predictor variables 'wt','I(wt^2)' account for 81.91 % of the total variation of your dependent variable 'mpg'. Your R^2 is quite good. The coefficient for 'wt' is  significantly different from zero(p< 0.001) The coefficient for 'I(wt^2)' is  significantly different from zero(p =0.003) The predicted value of dependent variable 'mpg' is calculated by the equation: '49.93 - 13.38*wt + 1.17*I(wt^2)'.

Multiple linear regression

fit=lm(mpg~hp+wt+am,data=mtcars)
ggPredict(fit)

cat(explain(fit))
The predictor variables 'hp','wt','am' account for 83.99 % of the total variation of your dependent variable 'mpg'. Your R^2 is quite good. The coefficient for 'hp' is smaller than zero. This means that the value of your dependent variable 'mpg' decreases by 0.037 for any increase of 1 in your independent variable 'hp', if 'wt','am' remain(s) constant. The coefficient is  significantly different from zero(p< 0.001), controlling for the other variable(s). The coefficient for 'wt' is smaller than zero. This means that the value of your dependent variable 'mpg' decreases by 2.88 for any increase of 1 in your independent variable 'wt', if 'hp','am' remain(s) constant. The coefficient is  significantly different from zero(p =0.004), controlling for the other variable(s). The coefficient for 'am' is larger than zero. This means that the value of your dependent variable 'mpg' increases by 2.08 for any increase of 1 in your independent variable 'am', if 'hp','wt' remain(s) constant. The coefficient is  not significantly different from zero(p =0.141) suggesting that 'am' and 'mpg' are not linearly related when controlling for other predictor variable(s). The predicted value of dependent variable 'mpg' is calculated by the equation: '34.00 - 0.04*hp - 2.88*wt + 2.08*am'.

Multiple linear regression with interaction

fit=lm(mpg~hp*wt,data=mtcars)
ggPredict(fit)

cat(explain(fit))
The predictor variables 'hp','wt' and the interaction 'hp:wt' account for 88.48 % of the total variation of your dependent variable 'mpg'. Your R^2 is quite good. The interaction between 'hp' and 'wt' is significant. This means that the relationship between one predictor and the response variable depends on the level of the other variable(s). Here it means that the relationship between 'mpg' and 'hp' varies by 'wt'. The predicted value of dependent variable 'mpg' is calculated by the equation: '49.81 - 0.12*hp - 8.22*wt + 0.03*hp*wt' which simplifies to '49.81 - 8.22*wt + (-0.12 + 0.03*wt)*hp'. If 'wt' is 2.24, the value of your dependent variable 'mpg' decreases by 0.058 for any increase of 1 in your independent variable 'hp' If 'wt' is 3.22, the value of your dependent variable 'mpg' decreases by 0.031 for any increase of 1 in your independent variable 'hp' If 'wt' is 4.2, the value of your dependent variable 'mpg' decreases by 0.0033 for any increase of 1 in your independent variable 'hp'
No. Subject Author Date
854 사소한 건의사항이 있습니다. [1] EPfunny 2015.11.15
853 Table에서 출력되는 수치의 정확도 관련 [9] o121 2017.11.21
852 다중회귀 관련 여러가지 질문들이 있습니다. [2] 짱이야 2018.05.04
851 R오류 문의드립니다. [1] 이엠티 2020.03.03
850 table 만들기에서, 나이 순으로 정렬시에 median 값과 범위를 지정할 수는 없는지요? [2] 혈액 2016.04.06
849 regression analysis 변수 소수점 갯수 수정이 가능할까요? 정아 2020.07.20
848 Trend test [1] namuhanayeyo 2017.02.04
847 psm 매칭 방법 및 SMD 관련하여 질문드립니다. [1] aaiek 2021.07.26
846 안녕하십니까, ROC curve AUC값 비교 (single predictors, regression models)에 대해서 여쭙습니다. [2] kjg 2021.12.25
845 머신러닝 레볼루션 행사안내 [1] mike 2016.03.10
844 로지스틱 회귀분석의 표본 추출에 관하여 문의드립니다 TAOKAKA 2019.01.12
843 my table 관련 질문 드립니다. [1] 김진아 2021.01.05
842 ggplot2 예제 [1] file cardiomoon 2015.12.18
841 logistic 분석 시 오류 문제 상의드립니다. [1] britnepak 2020.12.01
840 로지스틱 분석 에러 [4] file 장진희 2015.04.08
839 표만들기 결과 값이 이해가 안되어 조언 부탁드리고자 올립니다. [1] file 멋진홍이 2017.11.23
838 메타분석에 대해 질문이 있습니다 [2] 카우보이 2016.04.01
837 로지스틱 회귀분석에서 신뢰구간의 표기 [1] BISONG 2018.12.07
836 heatmapannotation함수 질문입니다 [1] sungmas 2020.06.05
835 안녕하세요 교수님. 여쭙고 싶은 것이 있어 글 올립니다. [2] yahello 2017.11.08