R 다중선형회귀분석

1 개요[ | ]

R multiple regression, R linear regression
R 다중회귀분석, R 선형회귀분석

2 예시 1: 광고 기억률[ | ]

df = data.frame(
  radio_ads = c(3,4,9,4,5,5,2,6,5,3),
  tv_ads    = c(1,3,4,1,4,1,4,2,4,2),
  retention = c(5,1,6,2,8,3,4,9,7,4)
)
model = lm(retention ~ radio_ads + tv_ads, data=df)
summary( model )
→ 회귀식 [math]\displaystyle{ y = 0.4725 x_1 - 0.5229 x_2 + 1.3670 }[/math]
→ 결정계수 [math]\displaystyle{ R^2 = 0.2517 }[/math]

3 예시 2: 빵집 매출[ | ]

df = read.csv('https://raw.githubusercontent.com/jmnote/zdata/master/multiple-regression/bakery-sales.csv')
head(df)
lm1 = lm(sales ~ floor_space + distance_to_station, data=df)
summary(lm1)
→ 회귀식 [math]\displaystyle{ y = 41.51348 x_1 - 0.34088 x_2 + 65.32392 }[/math]
→ 결정계수 [math]\displaystyle{ R^2 = 0.9452 }[/math]

4 예시 3: mtcars[ | ]

head(mtcars)
model = lm(mpg ~ ., data=mtcars)
summary(model)

5 예시 4: Boston[ | ]

library(MASS) # Boston
head(Boston)
model = lm(medv ~ ., data=Boston)
summary(model)

6 같이 보기[ | ]

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