##7.24 Nutrition at Starbucks
##a) It is a linear positive relationship but the strength is weal as points are spread far apart.
##b) Explanatory: Calories, Response: Carbohydrates (in grams)
##c) WE might want to predict the amount of carbohydrates from a known number of calories.
##d) Independence: Satisfied, assuming food items are independent of each other.
##  Linear: satisfied, as the scatterplots and residuals plots do not show strong curvature.
##  Equal variance: not satisfied, residuals plot not evenly distributed.
##  normal residuals: satisfied, histogram is roughly normal and unimodal.

##7.26 Body measurements
##a) y=b0 + b1*x
b1<-0.67*9.41/10.37
b0<-171.14-b1*107.20
b1
## [1] 0.6079749
b0
## [1] 105.9651
##y=105.97 + 0.607x
##b) The average height at a girth of 0 is 106.97cm
##  The height increases by 0.607cm per 1cm of girth
##c) Rsquare=0.67^2=44.89%
##44.89% of the variation in height is explained by shoulder girth.
##d) x=100
105.97+0.607*100
## [1] 166.67
##Height calculated is 166.67cm
##e) Overestimation is 
160-166.67
## [1] -6.67
##f) The observation is more than 3 standard deviations from the mean and therefore the model cannot be used.

##7.30 Cats
##a) HeartWeight=-0.357 + 4.034*BodyWeight
##b) HeartWight of cats with 0 body eight is -0.357, which does not make sense.
##c) For each additional 1 kg in body weight, we xpect heart weight to increase by 4.034g
##d) RSquare=64.66%, About 65% of the change in heart weight is explained by this linear model.
##e) Correlation coefficient =sqrt(64.66%)=0.804

##7.40 Rate my professor
##a) Slope = 4.13 * 0.0322 = 0.1329
##b) Ho: B1<0
##   Ha: B1>0
## p value=0
##Since p<0.05, we may reject Ho, so the data provides evidence that the slope of the linear relationship between teaching evaluation and beauty is positive.
##c) Linear: satisfied, as we can see from the qq plot, the points are close to the line.
##  Normal: satisfied, distribution of residuals is approximately normal
##  Constant variability: satisfied, from the look of the residual plot.