728x90

회귀분석이란?

데이터 X, Y 가 있을 때 데이터 X, Y를 잘 설명하는 선형식 y= aX + b 즉 계수 a, b 를 구하는 분석방법이라고 생각하면 됩니다.

 

# R로 하는 회귀분석

wei <- c(65,66,69,67,68,69)

hei <- c(171,173,176,174,175,178)

age <- c(23,24,38,43,40,42)

health <- data.frame(wei,hei,age)

plot(hei,wei)

lm(wei~hei,data=health)

#lm(health$wei~health$hei)

model_lm <- lm(wei~hei,data=health) 

# 예전에는 result_lm <- lm(wei~hei,data=health) 과 같이 이해하기 쉽게 변수명을 result_lm 같이 사용했는데 머신러닝 강의를 미리 익숙해 지도록 "R 통계학" 강의에도 변수 이름을 model_ 을 붙이기로 했습니다.  

summary(model_lm)

plot(wei~hei,data=health)

abline(model_lm,col='red')

names(model_lm)

# [1] "coefficients" "residuals" "effects" "rank" "fitted.values" "assign" "qr"

# [8] "df.residual" "xlevels" "call" "terms" "model"

 

+ Recent posts