The cost of a leading liquid laundry detergent in different sizes is given below.
Size (ounces) | Cost ($) | Cost per ounce |
---|---|---|
16 | 3.69 | |
32 | 4.59 | |
64 | 5.89 | |
200 | 10.39 |
Part A) Using "size" as the independent variable and "cost" as the dependent variable, make a scatter plot.
Part B) Does it appear from inspection that there is a relationship between the variables? Why or why not?
Part C) Calculate the least squares line. Put the equation in the form of: ŷ = a + bx. (Round your answers to three decimal places.)
Part D) Find the correlation coefficient r. (Round your answer to four decimal places.)
Part E) If the laundry detergent were sold in a 30-ounce size, find the estimated cost. (Use your equation from part (c). Round your answer to two decimal places.)
Part F) If the laundry detergent were sold in an 86-ounce size, find the estimated cost. (Use your equation from part (c). Round your answer to two decimal places.)
Part G) What is the slope of the least squares (best-fit) line?
(Round your answer to three decimal places.)
The relevant R code is as follows:
# loading dataset
dataset <- data.frame(Size = c(16, 32, 64, 200), Cost = c(3.69,
4.59, 5.89, 10.39))
# making scatterplot
plot(x = dataset$Size, y = dataset$Cost, xlab = "Size", ylab =
"Cost", main = "Scatterplot")
# seems to be a linear relationshipt with positive correlation
# calculating least squares line
(ls_line <- lm(formula = (dataset$Cost ~ dataset$Size)))
# regression line is y_hat = 3.377 + 0.035x
# finding correlation coefficient
(r <- cor(x = dataset$Size, y = dataset$Cost))
# correlation coefficient is r = 0.9974
# finding cost for 30 ounce size
(cost_est_30 <- (3.377 + 0.035 * 30))
# estimated cost is $4.43
# finding cost for 86 ounce size
(cost_est_86 <- (3.377 + 0.035 * 86))
# estimated cost is $6.39
# slope of the best fit line
(slope <- ls_line$coefficients[2])
# slope is 0.035
Get Answers For Free
Most questions answered within 1 hours.