"R 다중선형회귀분석"의 두 판 사이의 차이

 
(같은 사용자의 중간 판 18개는 보이지 않습니다)
1번째 줄: 1번째 줄:
==개요==
==개요==
;R multiple regression
;R multiple regression, R linear regression
;R 다중회귀분석
;R 다중회귀분석, R 선형회귀분석


==예시 1: 광고 기억률==
==예시 1: 광고 기억률==
<source lang='r' run>
<syntaxhighlight lang='r' notebook>
df <- data.frame(
df = data.frame(
   radio_ads = c(3,4,9,4,5,5,2,6,5,3),
   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),
   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)
   retention = c(5,1,6,2,8,3,4,9,7,4)
)
)
model <- lm(retention ~ radio_ads + tv_ads, data=df)
model = lm(retention ~ radio_ads + tv_ads, data=df)
summary( model )
summary( model )
</source>
</syntaxhighlight>
:→ 회귀식 <math>y = 0.4725 x_1 - 0.5229 x_2 + 1.3670</math>
:→ 회귀식 <math>y = 0.4725 x_1 - 0.5229 x_2 + 1.3670</math>
:→ 결정계수 <math>R^2 = 0.2517</math>
:→ 결정계수 <math>R^2 = 0.2517</math>


==예시 2: 빵집 매출==
==예시 2: 빵집 매출==
<source lang='r' run>
<syntaxhighlight lang='r' notebook='빵집'>
df <- read.csv('https://raw.githubusercontent.com/jmnote/z-dataset/master/multiple-regression/bakery-sales.csv')
df = read.csv('https://raw.githubusercontent.com/jmnote/zdata/master/multiple-regression/bakery-sales.csv')
df
head(df)
lm1 <- lm(sales ~ floor_space + distance_to_station, data=df)
</syntaxhighlight>
<syntaxhighlight lang='r' notebook='빵집'>
lm1 = lm(sales ~ floor_space + distance_to_station, data=df)
summary(lm1)
summary(lm1)
</source>
</syntaxhighlight>
:→ 회귀식 <math>y = 41.51348 x_1 - 0.34088 x_2 + 65.32392</math>
:→ 회귀식 <math>y = 41.51348 x_1 - 0.34088 x_2 + 65.32392</math>
:→ 결정계수 <math>R^2 = 0.9452</math>
:→ 결정계수 <math>R^2 = 0.9452</math>
==예시 3: mtcars==
<syntaxhighlight lang='r' notebook='mtcars'>
head(mtcars)
</syntaxhighlight>
<syntaxhighlight lang='r' notebook='mtcars'>
model = lm(mpg ~ ., data=mtcars)
summary(model)
</syntaxhighlight>
==예시 4: Boston==
<syntaxhighlight lang='r' notebook='boston'>
library(MASS) # Boston
head(Boston)
</syntaxhighlight>
<syntaxhighlight lang='r' notebook='boston'>
model = lm(medv ~ ., data=Boston)
summary(model)
</syntaxhighlight>


==같이 보기==
==같이 보기==
* [[다중회귀분석]]
* [[R 단순회귀분석]]
* [[R 단순회귀분석]]
* [[R 리지 회귀분석]]
* [[R 라쏘 회귀분석]]
* [[R 로지스틱회귀분석]]
* [[R 로지스틱회귀분석]]
* [[다중회귀분석]]
* [[Sklearn 다중회귀분석]]
* [[Statsmodels 다중회귀분석]]


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

2021년 10월 1일 (금) 17:14 기준 최신판

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