Q) 데이터 toothgrowth는 오렌지 주스(oj)와 비타민 c (vc)를 다양한
농도(dose)로 섭취하였을때 치아 모세포(odontoblast)의 길이(len)에 미치는
영향에 관한 데이터이다.오렌지 주스와 비타민 c 섭취수준 (dose)이
치아모세포길이(len)에 미치는 영향을 비교하세요.
dat <- ToothGrowth
head(dat)
## len supp dose
## 1 4.2 VC 0.5
## 2 11.5 VC 0.5
## 3 7.3 VC 0.5
## 4 5.8 VC 0.5
## 5 6.4 VC 0.5
## 6 10.0 VC 0.5
OJ와 VC의 dose을 각각 한개의 그룹으로 묶기
OJ_dose <- subset(dat, supp == "OJ")
OJ_dose
## len supp dose
## 31 15.2 OJ 0.5
## 32 21.5 OJ 0.5
## 33 17.6 OJ 0.5
## 34 9.7 OJ 0.5
## 35 14.5 OJ 0.5
## 36 10.0 OJ 0.5
## 37 8.2 OJ 0.5
## 38 9.4 OJ 0.5
## 39 16.5 OJ 0.5
## 40 9.7 OJ 0.5
## 41 19.7 OJ 1.0
## 42 23.3 OJ 1.0
## 43 23.6 OJ 1.0
## 44 26.4 OJ 1.0
## 45 20.0 OJ 1.0
## 46 25.2 OJ 1.0
## 47 25.8 OJ 1.0
## 48 21.2 OJ 1.0
## 49 14.5 OJ 1.0
## 50 27.3 OJ 1.0
## 51 25.5 OJ 2.0
## 52 26.4 OJ 2.0
## 53 22.4 OJ 2.0
## 54 24.5 OJ 2.0
## 55 24.8 OJ 2.0
## 56 30.9 OJ 2.0
## 57 26.4 OJ 2.0
## 58 27.3 OJ 2.0
## 59 29.4 OJ 2.0
## 60 23.0 OJ 2.0
VC_dose <- subset(dat, supp == "VC")
VC_dose
## len supp dose
## 1 4.2 VC 0.5
## 2 11.5 VC 0.5
## 3 7.3 VC 0.5
## 4 5.8 VC 0.5
## 5 6.4 VC 0.5
## 6 10.0 VC 0.5
## 7 11.2 VC 0.5
## 8 11.2 VC 0.5
## 9 5.2 VC 0.5
## 10 7.0 VC 0.5
## 11 16.5 VC 1.0
## 12 16.5 VC 1.0
## 13 15.2 VC 1.0
## 14 17.3 VC 1.0
## 15 22.5 VC 1.0
## 16 17.3 VC 1.0
## 17 13.6 VC 1.0
## 18 14.5 VC 1.0
## 19 18.8 VC 1.0
## 20 15.5 VC 1.0
## 21 23.6 VC 2.0
## 22 18.5 VC 2.0
## 23 33.9 VC 2.0
## 24 25.5 VC 2.0
## 25 26.4 VC 2.0
## 26 32.5 VC 2.0
## 27 26.7 VC 2.0
## 28 21.5 VC 2.0
## 29 23.3 VC 2.0
## 30 29.5 VC 2.0
OJ에 대한 선형 회귀 분석결과
- p value는 1.825e-06 이고 r^2는 0.5626이다
model_OJ <- lm(len ~ dose, data = OJ_dose)
summary(model_OJ)
##
## Call:
## lm(formula = len ~ dose, data = OJ_dose)
##
## Residuals:
## Min 1Q Median 3Q Max
## -7.2557 -3.7979 -0.0643 3.3521 7.9386
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 11.550 1.722 6.708 2.79e-07 ***
## dose 7.811 1.302 6.001 1.82e-06 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 4.446 on 28 degrees of freedom
## Multiple R-squared: 0.5626, Adjusted R-squared: 0.547
## F-statistic: 36.01 on 1 and 28 DF, p-value: 1.825e-06
VC에 대한 선형회귀 분석결과
- p value는 1.509e-11 이고 r^2는 0.8082이다
model_VC <- lm(len ~ dose, data = VC_dose)
summary(model_VC)
##
## Call:
## lm(formula = len ~ dose, data = VC_dose)
##
## Residuals:
## Min 1Q Median 3Q Max
## -8.2264 -2.6029 0.0814 2.2288 7.4893
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.295 1.427 2.309 0.0285 *
## dose 11.716 1.079 10.860 1.51e-11 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 3.685 on 28 degrees of freedom
## Multiple R-squared: 0.8082, Adjusted R-squared: 0.8013
## F-statistic: 117.9 on 1 and 28 DF, p-value: 1.509e-11
오랜지 주스의 산점도와 회귀선 그리기
plot(OJ_dose$dose, OJ_dose$len, main = "OJ",
xlab = "Dose of Orange Juice", ylab = "length")
abline(model_OJ, col = "red")

plot(VC_dose$dose, VC_dose$len, main = "VC",
xlab = "Dose of Vitamin C", ylab = "length")
abline(model_VC, col = "red")

- 결과: 서로 각각의 p value가 0.05보다 작으므로 귀무가설을 기가한다.
즉, 오렌지 주스와 비타민 C의 섭취(dose)이 치아길이에 영향이 미치지
않다고 판단 할 수 없다. Note that the
echo = FALSE
parameter was added to the code chunk to prevent printing of the R code
that generated the plot.