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

 
(같은 사용자의 중간 판 8개는 보이지 않습니다)
7번째 줄: 7번째 줄:


==예시 1: 키와 몸무게 ==
==예시 1: 키와 몸무게 ==
<syntaxhighlight lang='r' run>
<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),
19번째 줄: 19번째 줄:


==예시 2: 대학 불합격==
==예시 2: 대학 불합격==
<syntaxhighlight lang='r' run>
<syntaxhighlight lang='r' notebook=2>
options(echo=TRUE)
df <- data.frame(
df <- data.frame(
   student = c(4000,10000,15000,12000,8000,16000,5000,7000,9000,10000),
   student = c(4000,10000,15000,12000,8000,16000,5000,7000,9000,10000),
33번째 줄: 32번째 줄:
==예시 3: 아이스티 주문==
==예시 3: 아이스티 주문==
<syntaxhighlight lang='r' notebook>
<syntaxhighlight lang='r' notebook>
df <- read.csv('https://raw.githubusercontent.com/jmnote/z-dataset/master/simple-regression/iced-tea-orders.csv')
df <- read.csv('https://raw.githubusercontent.com/jmnote/ds/main/simple-regression/iced-tea-orders.csv')
df
head(df)
</syntaxhighlight>
</syntaxhighlight>
<syntaxhighlight lang='r' notebook>
<syntaxhighlight lang='r' notebook>
40번째 줄: 39번째 줄:
summary(model)
summary(model)
</syntaxhighlight>
</syntaxhighlight>
<syntaxhighlight lang='r' notebook>
:→ 회귀식 <math>y=3.7379x-36.3612</math>
:→ 회귀식 <math>y=3.7379x-36.3612</math>
:→ 결정계수 <math>R^2=0.8225</math>
:→ 결정계수 <math>R^2=0.8225</math>

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 }}