Accuracy of coefficients on log-linear regressiosn

Consider the following two regression models using data from the table below.

1. $$ln(wage)=\beta_0+\beta_1 female+u$$

2. $$ln(wage)=\gamma _0+\gamma_1 male+v$$

wage female male
10 1 0
20 1 0
30 1 0
40 1 0
50 1 0
15 0 1
30 0 1
45 0 1
60 0 1
75 0 1

I believe $$\beta_1$$ in the first model can be interpreted as the percent by which average wages differ for female employees relative to male employees. Likewise, $$\gamma_1$$ in the second model can be interpreted as the percent by which average wages differ for male employees relative to female employees. The estimates for $$\beta_1$$ and $$\gamma_1$$ using OLS are $$-0.4055$$ and $$0.4055$$ respectively.

Here is my source of confusion. In this dataset, females have an average wage of $$\30$$ and males have an average wage of $$\45$$. This means that men on average earn $$50\%$$ more than women (not $$40.55\%$$ more) and females earn $$33\%$$ less than men (not $$40.55\%$$ less). Why is there such a great discrepancy between the OLS estimates and estimates using the means for male and female wage? Are my interpretations for $$\beta_1$$ wrong, or is there something else I do not understand about this regression method?

Your confusion is due to a very common mistake that I have blogged about here.

When you take the log of the outcome, you make the assumption that $$\log(y) \vert x$$ is normally distributed. In your case, log wage is normal conditional on sex.

The intercept from your regression is then an estimate of the median wage, not the mean. Thus, the coefficients represent changes in the median on the appropriate scale. In order to get an estimate of the mean wage from your regression, you need to add a factor of $$\sigma^2/2$$ to the prediction. Here is some python code to demonstrate that

from statsmodels.regression.linear_model import OLS
import numpy as np
import pandas as pd

wage = np.array([10, 20, 30, 40, 50, 15, 30, 45, 60, 75])
fem = np.array([1, 1, 1, 1, 1, 0, 0, 0, 0, 0])

fit = OLS(np.log(wage), X).fit()

#median wages
np.exp(fit.params.cumsum()).round()
array([39., 26.])

#mean wages
sig = np.var(fit.resid)

np.exp(fit.params.cumsum() + sig/2)
array([46., 31.]) # Close, not perfect, likely due to small sample size and rounding

$$$$
`
• In my table, the mean and median wage are the same for males and females. It is still not clear to me how $\beta_1$ can be interpreted as the percent by which median wages differ for female employees relative to male employees since $\beta_1=−0.4055$ rather than $-0.3333$. Commented Aug 17, 2022 at 14:32