6
$\begingroup$

I'm reading Gelman and Hill 'Data Analysis using linear regression and multilevel/hierarchical models'. I have a problem with exercise 2 in chapter 3.

Suppose that, for a certain population, we can predict log earnings from log height as follows:

  • A person who is 66 inches tall is predicted to have earnings of $30,000. Every increase of 1% in height corresponds to a predicted increase of 0.8% in earnings.
  • The earnings of approximately 95% of people fall within a factor of 1.1 of predicted values.
  • Give the equation of the regression line and the residual standard deviation of the regression.

Suppose the standard deviation of log heights is 5% in this population. What, then, is the R2 of the regression model described here?

In R, I've used the following code to derive the equation for the regression line

alpha = log(30000) - (0.008/0.01) * log(66) # find the y-intercept
alpha
log.y = alpha + (0.008/0.01) * log(66) 
exp(log.y) # we need to take the exponential of log.y to have our final result

The equation is $log(\text{earnings}) = 6.957229 + \frac{0.008}{0.01} * log(\text{height})$. To compute the standard deviation of the predictions, I've used a simple equation based on the second bullet point fact.

sd =  0.1 * .50 / .95

This returns a standard deviation for the residual of the regression of $0.05263158$. I have a hard time though when trying to resolve the last question; what is the R2 of our model?

sd.population = 0.05
R2 <- 1 - (sd^2 / sd.population^2)

This however returns a negative R-squared, which is clearly wrong. What am I doing wrong?

$\endgroup$
3
  • 2
    $\begingroup$ Is the ratio of 0.08/0.01 what you intended? Should this not be 0.008/0.01? $\endgroup$
    – t-student
    Commented Oct 26, 2015 at 13:14
  • $\begingroup$ You're absolutely right Mark, I'm going to edit my initial post. $\endgroup$
    – Gianluca
    Commented Oct 26, 2015 at 13:31
  • 1
    $\begingroup$ please add [self-study] tag to your question. $\endgroup$
    – Tim
    Commented Oct 26, 2015 at 13:34

3 Answers 3

2
$\begingroup$

With these kinds of questions it is usually best to eschew computer coding until you are at least able to write down the various algebraic equations you are using. The key for these questions is to be able to interpret the written information to obtain corresponding algebraic equations from your model. Once you have the available conditions written down, that is more than half the battle, and solving them is usually fairly straightforward.


Letting $x_i$ be height (in inches) and $Y_i$ be earnings (in $1,000s), the log-linear model is:

$$\ln Y_i = \beta_0 + \beta_1 \ln x_i + \varepsilon_i \quad \quad \quad \varepsilon_i \sim \text{N}(0,\sigma^2).$$

Taking expectations gives the true regression line for the model:

$$\mathbb{E}(\ln Y_i|x_i) = \beta_0 + \beta_1 \ln x_i. \quad$$

The estimated regression line for the model is:

$$\quad \text{ } \ln \hat{Y}_i = \hat{\beta}_0 + \hat{\beta}_1 \ln x_i.$$

Since both of the variables enter the model through their logarithms, the parameter $\beta_1$ represents the elasticity of the expected earning with respect to height, and the parameter $\beta_0$ represents the expected log-earnings when the height is one unit (though this interpretation extrapolates beyond the data range). From the stated conditions we have the following three mathematical conditions:

A person who is 66 inches tall is predicted to have earnings of $30,000.

$$\ln 30 = \hat{\beta}_0 + \hat{\beta}_1 \ln 66.$$

Every increase of 1% in height corresponds to a predicted increase of 0.8% in earnings.

$$\hat{\beta}_1 = \frac{0.008}{0.01} = 0.8$$

The earnings of approximately 95% of people fall within a factor of 1.1 of predicted values.

$$\mathbb{P}( |\ln Y_i - \ln \hat{Y}_i| \leqslant 0.1 ) \approx 0.95.$$

Suppose the standard deviation of log heights is 5% in this population.

$$MS_{Tot} = 0.05^2.$$

So now, you need to use these conditions to find the various parameter estimates in the model, and the resultant goodness-of-fit statistics. The first two equations will allow you to find the coefficient estimates, and the third should then allow you to find the estimated standard deviation of the error term. (You might need an additional assumption for this one.) The fourth equation will then allow you to find the goodness-of-fit statistics for the model.

$\endgroup$
-1
$\begingroup$

log(x) - log(y) ~ %$delta$

So log(x) - log(y) + 1.96$\sigma$ = 1.1 implies that $\sigma$ = 1.78.

With standard deviation of log earnings (Gelman has heights in the book, but I think this is an error) at 5(%), R2 = 1 - 1.78 /5 = .64

$\endgroup$
-1
$\begingroup$

I had a different interpretation of (b). we have $\log(y) = a + b\log(x)$ from the regression. Hence, $$sd(\log(y)) = |b|sd(\log(x)) = (0.8)\times(0.05)=0.04,$$

since $sd(\log(x))$ is given. Squaring this we get the regression sum of squares $SSR = 0.0016$. From (a) we have the residual standard deviation ($0.049$). Squaring this yields the error sum of squares $SSE = 0.0024.$ Thus, the total sum of squares on the log scale equals 0.004, giving an R-squared of $1 - 0.0016/0.004 = 0.6$

$\endgroup$
2
  • 1
    $\begingroup$ Welcome to the site. I took the liberty of formatting your math, please have a look to see that it's still correct $\endgroup$
    – einar
    Commented Nov 1, 2017 at 14:37
  • $\begingroup$ Sorry to necro an old post: where exactly does 0.049 come from? I believe I am missing some basic algebra. $\endgroup$
    – user226134
    Commented Jul 21, 2019 at 22:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.