Dear Statalist

I have gone through Tobit model in very a detailed way but reached a dead-end in trying to calculate the marginal effect for an IV Tobit model manually (NOT margins command) and I need your kind assistance please. As far as I know, if I want to calculate marginal effect manually (whether using nlcom or predictnl or whatsoever) for a tobit model with no endogenous variable I could simply do the following:

tobit Y X1 X2

predict xbeta, xb
egen avxbeta=mean(xbeta)
gen avxbsig=avxbeta/_b[/sigma]
gen lambda=normalden(avxbsig)/normal(avxbsig)
gen partial=_b[X1]*(1-lambda*(avxbsig+lambda))
sum partial

which satisfies:

margins, dydx(X1) predict(e(0,.)) atmeans


My question is: how can I do it if X1 is endogenous instrumented by Z1 as follows.

reg X1 Z1 X2
predict res, residual
tobit Y X1 X2 res

OR Simply put, for the code:
ivtobit Y (X1 = Z1) X2

how can I obtain [margins, dydx(X1) predict(e(0,.)) atmeans] mannually using nlcom or predictnl or any other way.

I know the ME calculation codes I posted above are not using nlcom or predictnl, but again please feel to provide codes using them.

Thanks in advance

Kind Regards
Thaer