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 안녕하십니까 교수님 PSM 결과에 대해 궁금한 것이 있어 여쭤봅니다 [2] secret 김도훈 2023.06.29
1213 교수님 지난 번 문의 드렸던 PSM 재문의 드립니다. [3] secret 긍정적인마음가짐 2023.06.27
1212 안녕하세요 ^^ odds ratio 와 관련된 문의드리고자 합니다 ^^ [2] 성열 2023.06.26
1211 mytable() 함수에서 na처리와 pvalue 계산 문의드립니다. [1] hjk34 2023.06.23
1210 교수님 안녕하세요 ^^ web-R table 작성관련 문의드립니다. [2] file mkw7654 2023.06.21
1209 Methods for continuous variables과 P value corrected for multiple comparisons 방법 궁금합니다. [1] 호호셀 2023.06.19
1208 ordinal logistic regression analysis 문의 [1] 버블 2023.06.18
1207 e-mail 변경 문의 [1] secret kimdo 2023.06.16
1206 안녕하세요 number at risk 관련 문의 드립니다 [1] secret cebukim 2023.06.13
1205 Propensity matching score 에 대해 문의드립니다. [1] saga 2023.06.08
1204 콕스비례위험모델의 적용에 관련해서 질문 드립니다. [2] secret kng1032 2023.06.07
1203 기초통계 계산 [2] secret leesav 2023.06.07
1202 정회원 후원하였습니다. [2] secret toast 2023.06.04
1201 logistic regression analysis 가 에러가 뜹니다. [1] secret Ikarus86 2023.06.02
1200 PMS caliper 에 대해 여쭤봅니다. [2] secret pjhaaa 2023.05.30
1199 ggGam에 대하여 [2] leesav 2023.05.22
1198 R 에서 PFS 의 confidence interval 을 구하고 싶을 때 어떻게 하면 될까요? [1] ddeeny 2023.05.21
1197 메타분석 관련 문의드립니다 secret 화이팅 2023.05.12
1196 교수님, 새로운 앱 개발 문의드립니다! [4] swpapa 2023.05.08
1195 교수님, 안녕하세요? 전용 앱 관련 문의드립니다! [1] swpapa 2023.05.07