Hello, I hope this answer helps you after so much time. You can use a cmp (Conditional mixed process estimator with multilevel random effects and coefficients) in stata. If you want to apply a cross-section model. In the CMP help you can see how to calculate the mills ratio to include into your second equation.