In this chapter we computed a least squares fit for penguin weights as a function of flipper length. There are two other measurements in the dataset we can also consider: culmen length and culmen depth (the culmen is the top ridge of the bill).
Based on the rvalue attribute of the RegressionResult object, what is the correlation of these variables? What is the coefficient of determination? Which is a better predictor of weight, culmen length or flipper length?
In this chapter we used resampling to approximate the sampling distribution for the slope of a fitted line. We can approximate the sampling distribution of the intercept the same way:
Write a function called estimate_intercept that takes a resampled DataFrame as an argument, computes the least squares fit of penguin weight as a function of flipper length, and returns the intercept.
Check that the standard error you get from resampling is consistent with the intercept_stderr attribute in the RegressionResult object -- it might be a little smaller.
A personβs Body Mass Index (BMI) is their weight in kilograms divided by their height in meters raised to the second power. In the BRFSS dataset, we can compute BMI like this, after converting heights from centimeters to meters.
In this definition, heights are squared, rather than raised to some other exponent, because of the observation -- early in the history of statistics -- that average weight increases roughly in proportion to height squared.
To see whether thatβs true, we can use data from the BRFSS, a least squares fit, and a little bit of math. Suppose weight is proportional to height raised to an unknown exponent, \(a\text{.}\) In that case, we can write:
\begin{equation*}
\log w = \log b + a \log h
\end{equation*}
So, if we compute a least squares fit for log-transformed weights as a function of log-transformed heights, the slope of the fitted line estimates the unknown exponent \(a\text{.}\)
Compute the logarithms of height and weight. You can use any base for the logarithms, as long as itβs the same for both transformations. Compute a least squares fit. Is the slope close to 2?