I have a question regarding the following error message: missing predicted values encountered within the estimation sample. It appears when I calculate the average partial effects (APE) after the Tobit regression.

I illustrate this point with an artificial dataset.

clear all
set seed 2038942
set obs 10000
gen i=_n

gen u=rnormal(0,0.5)
mat m=(0, 1, 2)
mat sd=(1, 2, 3)
drawnorm x1 x2 x3, means(m) sds(sd)
gen y=2*x1+4*x2-0.5*x3+u
replace y=cond(y>0, y, 0)
This is a dataset where the dependent variable is y (left-censored at 0) and the independent variables are x1, x2 and x3.

Then I ran the Tobit model on my data

tobit y x1 x2 x3, ll(0)
After that, I calculated the APE for E[y|x], which is

margins, dydx(_all) predict(ystar(0,.))
Then, I got the error message mentioned in the beginning.

My understanding of the reason for this message is that the calculation of APE involves the inverse mill ratio (IMR). The denominator of the IMR is the cdf of the standard normal distribution ϕ(xb). If the linear predictions xb for some observations are very negative, then Stata treats the ϕ(xb) as zero, despite that the 'true' ϕ(xb) is not. Thus, I get some 'missing predicted values'.

To verify this thought, I made the following prediction for each observation.

predict y_hat, ystar(0,.)
Indeed I got 50 missing values. I checked their ϕ(xb):

tobit y x1 x2 x3, ll(0)
scalar sd=sqrt(e(b)[1,5])
predict y_fit, xb
gen Phi=normal(y_fit/sd)
I found their ϕ(xb) were indeed calculated as 0.

Does anyone know if my understanding of the presence of missing values is correct? If so, is there any suggestions on how to write the margin command to avoid this error message (i.e. Stata can ignore the missing values)? Thank you for your suggestions.