##
## Welcome to CUNY DATA606 Statistics and Probability for Data Analytics
## This package is designed to support this course. The text book used
## is OpenIntro Statistics, 3rd Edition. You can read this by typing
## vignette('os3') or visit www.OpenIntro.org.
##
## The getLabs() function will return a list of the labs available.
##
## The demo(package='DATA606') will list the demos that are available.
Graded: 7.24, 7.26, 7.30, 7.40
7.24 Nutrition at Starbucks, Part I. The scatterplot below shows the relationship between the number of calories and amount of carbohydrates (in grams) Starbucks food menu items contain.21 Since Starbucks only lists the number of calories on the display items, we are interested in predicting the amount of carbs a menu item has based on its calorie content.
Describe the relationship between number of calories and amount of carbohydrates (in grams) that Starbucks food menu items contain.
There appears to be a loose, linear relationship. There is high variability between the variables.
In this scenario, what are the explanatory and response variables?
Why might we want to fit a regression line to these data?
A regression line could predict the amount of carbs based on number of calories.
Do these data meet the conditions required for fitting a least squares line?
Conditions: Linearity, nearly normal residuals, constant variability, & independent observations.
I believe that there is not enough constant variability or normal enough distribution of residuals to meet the requirements for fitting a least squares line.
7.26 Body measurements, Part III. Exercise 7.15 introduces data on shoulder girth and height of a group of individuals. The mean shoulder girth is 107.20 cm with a standard deviation of 10.37 cm. The mean height is 171.14 cm with a standard deviation of 9.41 cm. The correlation between height and shoulder girth is 0.67.
Write the equation of the regression line for predicting height.
\[ \hat{y} = 105.9650878 + 0.6079749 * height \]
m.shld <- 107.20
sd.shld <- 10.37
m.hgt <- 171.14
sd.hgt <- 9.41
c <- .67
b1 <- (sd.hgt/sd.shld)*c
b0 <- m.hgt - b1 * m.shld
b1## [1] 0.6079749
b0## [1] 105.9651
Interpret the slope and the intercept in this context.
For every cm of increased height, the cm increase of shoulder girth.
Calculate R2 of the regression line for predicting height from shoulder girth, and interpret it in the context of the application.
The model explains about 45% of the variation in the height variable.
r2 <- (c^2)
r2## [1] 0.4489
A randomly selected student from your class has a shoulder girth of 100 cm. Predict the height of this student using the model.
Prediction: height = 166.76 cm
predicted <- b0 + b1 * 100
predicted## [1] 166.7626
The student from part d. is 160 cm tall. Calculate the residual, and explain what this residual means.
Residual: -6.76cm. The negative value indicates we overestimated by 6.76 cm.
i <- 100
yi <- 160
ei <- yi - predicted
ei## [1] -6.762581
A one year old has a shoulder girth of 56 cm. Would it be appropriate to use this linear model to predict the height of this child?
56 cm falls outside of the scope of this linear model. It would not be a good predictive indicator of height for this child.
7.30 Cats, Part I. The following regression output is for predicting the heart weight (in g) of cats from their body weight (in kg). The coefficients are estimated using a dataset of 144 domestic cats.
| Estimate | Std. Error | t value | Pr(>|t|) | |
|---|---|---|---|---|
| (intercept) | -0.357 | 0.692 | -0.515 | 0.607 |
| body wt | 4.034 | 0.25 | 16.119 | 0 |
| s=1.452 | R^2 = 64.66% | R^2adj=64.41% |
Write out the linear model.
\[ \hat{y} = -0.357 + 4.034 * x \]
Interpret the intercept.
The negative intercept means that when the cat’s weight is 0, the heart’s weight would be -0.357.
Interpret the slope.
The positive slope means that for each kilogram of body weight, the average heart weight of a cat should increase by 4.034 grams.
Interpret R2.
R\(^2\): 64.66%. This means that 64.66% variability in cat’s heart weight can be explained by body weight
Calculate the correlation coeficient.
Correlation coeficient: 0.8041144
sqrt(.6466)## [1] 0.8041144
7.40 Rate my professor. Many college courses conclude by giving students the opportunity to evaluate the course and the instructor anonymously. However, the use of these student evaluations as an indicator of course quality and teaching effectiveness is often criticized because these measures may reflect the influence of non-teaching related characteristics, such as the physical appearance of the instructor. Researchers at University of Texas, Austin collected data on teaching evaluation score (higher score means better) and standardized beauty score (a score of 0 means average, negative score means below average, and a positive score means above average) for a sample of 463 professors. The scatterplot below shows the relationship between these variables, and also provided is a regression output for predicting teaching evaluation score from beauty score.
Given that the average standardized beauty score is -0.0883 and average teaching evaluation score is 3.9983, calculate the slope. Alternatively, the slope may be computed using just the information provided in the model summary table.
Slope: 0.1325
b0 <- 4.010
x <- -0.0883
y <- 3.9983
b1 <- (y - b0) / x
b1## [1] 0.1325028
Do these data provide convincing evidence that the slope of the relationship between teaching evaluation and beauty is positive? Explain your reasoning.
Yes, the slope is positive which suggests the relationship between teaching evaluations and beauty is positive.
List the conditions required for linear regression and check if each one is satisified for this model based on the following diagnostic plots.
Conditions: Linearity, nearly normal residuals, constant variability, & independent observations.
All conditions appear to be satisfied.