library(ggplot2)
library(dplyr)
# Prettier graphs
theme_set(theme_bw())
In professional basketball games during the 2009-2010 season, when
Kobe Bryant of the Los Angeles Lakers shot a pair of free throws, 8
times he missed both, 152 times he made both, 33 times he made only the
first shot, and 37 times he made only the second. Is it possible that
the successive free throws are independent, or is there evidence to
suggest a “hot streak” effect? The data are tabulated in the
freethrow
data frame below:
# Create freethrow data (copy and paste this into your own R session)
freethrow <- matrix(c(152,33,37,8), nrow = 2, byrow = TRUE)
rownames(freethrow) <- c("Make 1st", "Miss 1st")
colnames(freethrow) <- c("Make 2nd", "Miss 2nd")
print(freethrow)
## Make 2nd Miss 2nd
## Make 1st 152 33
## Miss 1st 37 8
Reconsider the anorexia data that we investigated in Homework 7:
anorexia <- read.csv("https://collinn.github.io/data/anorexia.txt")
mutate
function to
again create a variable called Diff
that records the
difference in pre and post weightsThis question will again consider the mtcars
dataset
built into R
data(mtcars)
We will be investigating the relationship between the weight of a car (independent variable) and its miles per gallon (dependent variable). In addition to this, we will also be using the number of carburetors as a second independent variable.
mpg
with the covariates wt
and
carb
. Based on the results, does it appear that the number
of carburetors has a relationship with fuel economy (mpg)?carb
is stored in
the dataset as an integer value. Use the mutate
function to create a new variable in the mtcars
dataset
called carb_factor
that is equal to
carb_factor = fator(carb)
. This will turn the new variable
into a categorical one instead of an integermpg
with wt
and
carb_factor
. What has changed this time? Specifically, what
do the covariates in the new model represent, and how is this different
from what we saw in Part A? (Hint: how do the estimates for
factor_carb
change as the number of carburetors
increases?)