"R 단순선형회귀분석"의 두 판 사이의 차이

 
(사용자 2명의 중간 판 32개는 보이지 않습니다)
1번째 줄: 1번째 줄:
==개요==
==개요==
;R simple regression
;R simple linear regression
;R simple linear regression
;R 회귀분석
;R 회귀분석
;R 단순회귀분석
;R 단순선형회귀분석
;R 단순선형회귀분석


<source lang='r'>
==예시 1: 키와 몸무게 ==
<syntaxhighlight lang='r' notebook>
df <- data.frame(
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),
   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)
   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)
model <- lm(mass ~ height, data=df)
summary(lm1)
summary(model)
## Call:
</syntaxhighlight>
## lm(formula = mass ~ height, data = df)
:→ 회귀식 <math>y=61.272x-39.062</math>
##
:→ 결정계수 <math>R^2=0.9892</math>
## Residuals:
 
##      Min      1Q  Median      3Q      Max
==예시 2: 대학 불합격==
## -0.88171 -0.64484 -0.06993  0.34095  1.39385
<syntaxhighlight lang='r' notebook=2>
##
df <- data.frame(
## Coefficients:
  student = c(4000,10000,15000,12000,8000,16000,5000,7000,9000,10000),
##            Estimate Std. Error t value Pr(>|t|)  
  rejection = c(100,400,500,400,300,400,200,100,400,200)
## (Intercept) -39.062      2.938  -13.29 6.05e-09 ***
)
## height        61.272      1.776  34.50 3.60e-14 ***
model <- lm(rejection ~ student, data=df)
## ---
summary(model)
## Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
</syntaxhighlight>
##
:→ 회귀식 <math>y=0.028902x+22.543353</math>
## Residual standard error: 0.7591 on 13 degrees of freedom
:→ 결정계수 <math>R^2=0.6423</math>
## Multiple R-squared: 0.9892, Adjusted R-squared:  0.9884
 
## F-statistic:  1190 on 1 and 13 DF, p-value: 3.604e-14
==예시 3: 아이스티 주문==
</source>
<syntaxhighlight lang='r' notebook>
df <- read.csv('https://raw.githubusercontent.com/jmnote/ds/main/simple-regression/iced-tea-orders.csv')
head(df)
</syntaxhighlight>
<syntaxhighlight lang='r' notebook>
model <- lm(order ~ high_temperature, data=df)
summary(model)
</syntaxhighlight>
:→ 회귀식 <math>y=3.7379x-36.3612</math>
:→ 결정계수 <math>R^2=0.8225</math>


==같이 보기==
==같이 보기==
* [[단순선형회귀분석]]
* [[단순회귀분석]]
* [[R 다중회귀분석]]
* [[R 분산분석]]
* [[R 분산분석]]
* [[R 로지스틱 회귀분석]]
* [[R 로지스틱 회귀분석]]


[[분류: R 회귀분석]]
[[분류: R 데이터 분석]]
[[분류: R 데이터 분석]]
[[분류: 회귀분석]]
[[분류: 회귀분석]]

2024년 1월 3일 (수) 13:01 기준 최신판

1 개요[ | ]

R simple regression
R simple linear regression
R 회귀분석
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)
)
model <- lm(mass ~ height, data=df)
summary(model)
→ 회귀식 [math]\displaystyle{ y=61.272x-39.062 }[/math]
→ 결정계수 [math]\displaystyle{ R^2=0.9892 }[/math]

3 예시 2: 대학 불합격[ | ]

df <- data.frame(
  student = c(4000,10000,15000,12000,8000,16000,5000,7000,9000,10000),
  rejection = c(100,400,500,400,300,400,200,100,400,200)
)
model <- lm(rejection ~ student, data=df)
summary(model)
→ 회귀식 [math]\displaystyle{ y=0.028902x+22.543353 }[/math]
→ 결정계수 [math]\displaystyle{ R^2=0.6423 }[/math]

4 예시 3: 아이스티 주문[ | ]

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

5 같이 보기[ | ]

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