Shiny App - Analysis on ToothGrowth Data

Ruzaini Amiraa Roslan

9/18/2020

Introduction

Data

Model Summary

data("ToothGrowth")
ToothGrowth$dose <- as.factor(ToothGrowth$dose)
model <- lm(len ~ ., data = ToothGrowth)
summary(model)
## 
## Call:
## lm(formula = len ~ ., data = ToothGrowth)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -7.085 -2.751 -0.800  2.446  9.650 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  12.4550     0.9883  12.603  < 2e-16 ***
## suppVC       -3.7000     0.9883  -3.744 0.000429 ***
## dose1         9.1300     1.2104   7.543 4.38e-10 ***
## dose2        15.4950     1.2104  12.802  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 3.828 on 56 degrees of freedom
## Multiple R-squared:  0.7623, Adjusted R-squared:  0.7496 
## F-statistic: 59.88 on 3 and 56 DF,  p-value: < 2.2e-16

Plots

Prediction for Supplement Type “OJ” and Dosage Amount of 1.0 mg/day

pred <- predict(model, newdata = data.frame(supp = "OJ", dose = as.factor(1.0)))
round(pred, 3)
##      1 
## 21.585