Non-linear regression with discrete explanatory variables, with an application to the earnings function