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
1214 Error in f(x, na.rm = TRUE) : 사용되지 않은 인자 (na.rm = TRUE) [2] twogama2 2017.09.18
1213 paired T test 문의드립니다. [1] ulysses11 2021.09.07
1212 [문의] Web RStudio안에서 R 패키지 설치관련 [1] 보석 2016.02.19
1211 Web-R 에서 logistic regression 시 p value 를 볼 수 있는 방법이 있나요? [2] 전공의 2017.08.15
1210 rstudio-server 패키지 설치오류 file 하리보는맛있어 2019.05.14
1209 Cut off value [2] 변변변수 2017.06.19
1208 문의드릴 사항이 있습니다. [7] 정지윤 2021.02.18
1207 mytable로 만든표를 워드파일로 변환 하는 방법 [3] 정암 2017.06.02
1206 안녕하세요 psm은 정회원만 이용 가능한가요? [1] Arete 2020.08.01
1205 안녕하세요 mytable 함수 관련하여 질문드립니다. [1] 지옥소년 2019.07.26
1204 범주형변수와 비정규분포 연속형 변수 간 관계를 볼때 이변량 상관관계 분석이 가능한지요? [1] 아라리 2018.05.30
1203 로지스틱 회귀분석 김밥친구 2018.10.04
1202 데이타 merge 방법 [5] nipponica 2017.02.18
1201 교수님, 다중공선성 질문드립니다. [2] selteen 2017.11.16
1200 2 way RM ANOVA 문의드립니다. file FAdavid 2021.01.19
1199 web-r에서 psm을 수행하였는데 레퍼런스는 어떻게 표시해야 하나요? [1] 스티브 2020.11.24
1198 Rstudio server 서버 오류 관련해서 문의드립니다. [2] file 노상래 2015.07.22
1197 엑셀파일 data 올릴시 maximal upload size exceeded [1] 딸기공주 2020.07.01
1196 생존분석에서 multivariate analysis에 대해 여쭙니다. [3] joon 2016.12.23
1195 정회원용 서버가 접속이 안됩니다. [1] 마늘맨 2018.02.16