R 단순선형회귀분석

Jmnote (토론 | 기여)님의 2020년 4월 2일 (목) 23:11 판 (→‎예시 2)

1 개요

R simple linear regression
R 회귀분석
R 단순선형회귀분석

2 예시 1

df <- data.frame(
  height = c(1.47, 1.50, 1.52, 1.55, 1.57, 1.60, 1.63, 1.65, 1.68, 1.70, 1.73, 1.75, 1.78, 1.80, 1.83),
  mass = c(52.21, 53.12, 54.48, 55.84, 57.20, 58.57, 59.93, 61.29, 63.11, 64.47, 66.28, 68.10, 69.92, 72.19, 74.46)
)
lm1 <- lm(mass ~ height, data=df)
summary(lm1)
## Call:
## lm(formula = mass ~ height, data = df)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.88171 -0.64484 -0.06993  0.34095  1.39385 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  -39.062      2.938  -13.29 6.05e-09 ***
## height        61.272      1.776   34.50 3.60e-14 ***
## ---
## Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
## 
## Residual standard error: 0.7591 on 13 degrees of freedom
## Multiple R-squared:  0.9892,	Adjusted R-squared:  0.9884 
## F-statistic:  1190 on 1 and 13 DF,  p-value: 3.604e-14

3 예시 2

df <- read.csv('https://raw.githubusercontent.com/jmnote/z-dataset/master/simple-regression/Norns-iced-tea-orders.csv')
df
lm1 <- lm(order ~ high_temperature, data=df)
summary(lm1)
→ 회귀식 [math]\displaystyle{ y=3.7379x-36.3612 }[/math]
→ 결정계수 [math]\displaystyle{ R^2=0.8225 }[/math]

4 같이 보기

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}