dat<-ToothGrowth
Independent Variable: The doses of OJ and VC consumed. Dependent Variable: The length of the odontoblast.
model<- lm(len~dose,data=dat)
summary(model)
##
## Call:
## lm(formula = len ~ dose, data = dat)
##
## Residuals:
## Min 1Q Median 3Q Max
## -8.4496 -2.7406 -0.7452 2.8344 10.1139
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 7.4225 1.2601 5.89 2.06e-07 ***
## dose 9.7636 0.9525 10.25 1.23e-14 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 4.601 on 58 degrees of freedom
## Multiple R-squared: 0.6443, Adjusted R-squared: 0.6382
## F-statistic: 105.1 on 1 and 58 DF, p-value: 1.233e-14
plot(dat$dose, dat$len, main="Scatterplot of Dose vs Len",
xlab="Dose", ylab="Tooth Length")
abline(model, col="red")
Since the p-value of the given data 1.233e-14 is smaller than the significance level of 0.05, we can conclude that the coefficient of the regression line is NOT 0; thus, there is a relationship between the does of VC/OG and the tooth length.
pairs(dat)
dat<-read.csv("/Users/nabinwon/Downloads/aminoAcid.csv")
Independent Variable: Doses of AminoAcid and its type Dependent Variable: The patient’s nutritional level
dat$AminoAcid<-as.factor(dat$AminoAcid)
dat$dose<-as.factor(dat$dose)
str(dat)
## 'data.frame': 18 obs. of 3 variables:
## $ AminoAcid: Factor w/ 2 levels "lysine","methionine": 2 2 2 2 2 2 2 2 2 1 ...
## $ dose : Factor w/ 3 levels "10","20","30": 1 1 1 2 2 2 3 3 3 1 ...
## $ response : num 15 16 14.5 17 19 18.5 14 13.5 14.5 30 ...
model <- lm(response ~ AminoAcid + dose, data = dat)
summary(model)
##
## Call:
## lm(formula = response ~ AminoAcid + dose, data = dat)
##
## Residuals:
## Min 1Q Median 3Q Max
## -4.8889 -2.9861 0.0833 2.6111 5.3889
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 32.861 1.729 19.005 2.15e-11 ***
## AminoAcidmethionine -20.222 1.729 -11.695 1.30e-08 ***
## dose20 3.667 2.118 1.731 0.1053
## dose30 5.750 2.118 2.715 0.0168 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 3.668 on 14 degrees of freedom
## Multiple R-squared: 0.9116, Adjusted R-squared: 0.8926
## F-statistic: 48.11 on 3 and 14 DF, p-value: 1.275e-07
Since the p-value of the given data 0.0137 and 4.20e-09 is less than the significance level of 0.05, we can conclude that the number of doses and the type of amino acid affects the patient’s nutritional level.