Thursday, February 26, 2026

Utilizing mlexp to estimate endogenous remedy results in a heteroskedastic probit mannequin


I take advantage of options new to Stata 14.1 to estimate a median remedy impact (ATE) for a heteroskedastic probit mannequin with an endogenous remedy. In 14.1, we added new prediction statistics after mlexp that margins can use to estimate an ATE.

I’m constructing on a earlier publish during which I demonstrated methods to use mlexp to estimate the parameters of a probit mannequin with an endogenous remedy and used margins to estimate the ATE for the mannequin Utilizing mlexp to estimate endogenous remedy results in a probit mannequin. At present, no official instructions estimate the heteroskedastic probit mannequin with an endogenous remedy, so on this publish I present how mlexp can be utilized to increase the fashions estimated by Stata.

Heteroskedastic probit mannequin

For binary consequence (y_i) and regressors ({bf x}_i), the probit mannequin assumes

[begin{equation}
y_i = {bf 1}({bf x}_i{boldsymbol beta} + epsilon_i > 0)
end{equation}]

The indicator operate ({bf 1}(cdot)) outputs 1 when its enter is true and outputs 0 in any other case. The error (epsilon_i) is customary regular.

Assuming that the error has fixed variance might not at all times be sensible. Suppose we’re learning a sure enterprise determination. Massive companies, as a result of they’ve the assets to take possibilities, might exhibit extra variation within the elements that have an effect on their determination than small companies.

Within the heteroskedastic probit mannequin, regressors ({bf w}_i) decide the variance of (epsilon_i). Following Harvey (1976), we now have

[begin{equation} mbox{Var}left(epsilon_iright) = left{expleft({bf
w}_i{boldsymbol gamma}right)right}^2 nonumber end{equation}]

Heteroskedastic probit mannequin with remedy

On this part, I evaluate the potential-outcome framework used to outline an ATE and prolong it for the heteroskedastic probit mannequin. For every remedy stage, there may be an consequence that we might observe if an individual had been to pick that remedy stage. When the end result is binary and there are two remedy ranges, we will specify how the potential outcomes (y_{0i}) and (y_{1i}) are generated from the regressors ({bf x}_i) and the error phrases (epsilon_{0i}) and (epsilon_{1i}):

[begin{eqnarray*}
y_{0i} &=& {bf 1}({bf x}_i{boldsymbol beta}_0 + epsilon_{0i} > 0) cr
y_{1i} &=& {bf 1}({bf x}_i{boldsymbol beta}_1 + epsilon_{1i} > 0)
end{eqnarray*}]

We assume a heteroskedastic probit mannequin for the potential outcomes. The errors are regular with imply (0) and conditional variance generated by regressors ({bf w}_i). On this publish, we assume equal variance of the potential consequence errors.

[begin{equation}
mbox{Var}left(epsilon_{0i}right) = mbox{Var}left(epsilon_{1i}right) =
left{expleft({bf w}_i{boldsymbol gamma}right)right}^2 nonumber
end{equation}]

The heteroskedastic probit mannequin for potential outcomes (y_{0i}) and (y_{1i}) with remedy (t_i) assumes that we observe the end result

[begin{equation}
y_i = (1-t_i) y_{0i} + t_i y_{1i}
nonumber
end{equation}]

So we observe (y_{1i}) underneath the remedy ((t_{i}=1)) and (y_{0i}) when the remedy is withheld ((t_{i}=0)).

The remedy (t_i) is set by regressors ({bf z}_i) and error (u_i):

[begin{equation}
t_i = {bf 1}({bf z}_i{boldsymbol psi} + u_i > 0)
nonumber
end{equation}]

The remedy error (u_i) is regular with imply zero, and we permit its variance to be decided by one other set of regressors ({bf v}_i):

[begin{equation}
mbox{Var}left(u_iright) =
left{expleft({bf v}_i{boldsymbol alpha}right)right}^2 nonumber
end{equation}]

Heteroskedastic probit mannequin with endogenous remedy

Within the earlier publish, I described methods to mannequin endogeneity for the remedy (t_i) by correlating the end result errors (epsilon_{0i}) and (epsilon_{1i}) with the remedy error (u_i). We use the identical framework for modeling endogeneity right here. The variance of the errors might change relying on the heteroskedasticity regressors ({bf w}_i) and ({bf v}_i), however their correlation stays fixed. The errors (epsilon_{0i}), (epsilon_{1i}), and (u_i) are trivariate regular with correlation

[begin{equation}
left[begin{matrix}
1 & rho_{01} & rho_{t} cr
rho_{01} & 1 & rho_{t} cr
rho_{t} & rho_{t} & 1
end{matrix}right]
nonumber
finish{equation}]

Now we now have all of the items we have to write the log probability of the heteroskedastic probit mannequin with an endogenous remedy. The type of the chances are just like what was given within the earlier publish. Now the inputs to the bivariate regular cumulative distribution operate, (Phi_2), are standardized by dividing by the conditional customary deviations of the errors.

The log probability for statement (i) is

[begin{eqnarray*}
ln L_i = & & {bf 1}(y_i =1 mbox{ and } t_i = 1) ln Phi_2left{frac{{bf x}_i{boldsymbol beta}_1}{expleft({bf w}_i{boldsymbol gamma}right)}, frac{{bf z}_i{boldsymbol psi}}{expleft({bf v}_i{boldsymbol alpha}right)},rho_tright} + cr
& & {bf 1}(y_i=0 mbox{ and } t_i=1)ln Phi_2left{frac{-{bf x}_i{boldsymbol beta}_1}{expleft({bf w}_i{boldsymbol gamma}right)}, frac{{bf z}_i{boldsymbol psi}}{expleft({bf v}_i{boldsymbol alpha}right)},-rho_tright} + cr
& & {bf 1}(y_i=1 mbox{ and } t_i=0) ln Phi_2left{frac{{bf x}_i{boldsymbol beta}_0}{expleft({bf w}_i{boldsymbol gamma}right)}, frac{-{bf z}_i{boldsymbol psi}}{expleft({bf v}_i{boldsymbol alpha}right)},-rho_tright} + cr
& & {bf 1}(y_i=0 mbox{ and } t_i = 0)ln Phi_2left{frac{-{bf x}_i{boldsymbol beta}_0}{expleft({bf w}_i{boldsymbol gamma}right)}, frac{-{bf z}_i{boldsymbol psi}}{expleft({bf v}_i{boldsymbol alpha}right)},rho_tright}
end{eqnarray*}]

The info

We’ll simulate knowledge from a heteroskedastic probit mannequin with an endogenous remedy after which estimate the parameters of the mannequin with mlexp. Then, we’ll use margins to estimate the ATE.


. set seed 323

. set obs 10000
variety of observations (_N) was 0, now 10,000

. generate x = .8*rnormal() + 4

. generate b = rpoisson(1)

. generate z = rnormal()

. matrix cm = (1, .3,.7  .3, 1, .7  .7, .7, 1)

. drawnorm ey0 ey1 et, corr(cm)

We simulate a random pattern of 10,000 observations. The remedy and consequence regressors are generated in the same method to their creation within the final publish. As within the final publish, we generate the errors with drawnorm to have correlation (0.7).


. generate g = runiform()

. generate h = rnormal()

. quietly substitute ey0 = ey0*exp(.5*g)

. quietly substitute ey1 = ey1*exp(.5*g)

. quietly substitute et = et*exp(.1*h)

. generate t = .5*x - .1*b + .5*z - 2.4 + et > 0

. generate y0 = .6*x - .8 + ey0 > 0

. generate y1 = .3*x - 1.3 + ey1 > 0

. generate y = (1-t)*y0 + t*y1

The uniform variable g is generated as a regressor for the end result error variance, whereas h is a regressor for the remedy error variance. We scale the errors by utilizing the variance regressors in order that they’re heteroskedastic, after which we generate the remedy and consequence indicators.

Estimating the mannequin parameters

Now, we’ll use mlexp to estimate the parameters of the heteroskedastic probit mannequin with an endogenous remedy. As within the earlier publish, we use the cond() operate to calculate completely different values of the probability based mostly on the completely different values of (y) and (t). We use the factor-variable operator ibn on (t) in equation y to permit for a special intercept at every stage of (t). An interplay between (t) and (x) can be laid out in equation y. This enables for a special coefficient on (x) at every stage of (t).


. mlexp (ln(cond(t, ///                                          
>         cond(y,binormal({y: i.t#c.x ibn.t}/exp({g:g}), ///
>             {t: x b z _cons}/exp({h:h}),{rho}), /// 
>                 binormal(-{y:}/exp({g:}),{t:}/exp({h:}),-{rho})), ///
>         cond(y,binormal({y:}/exp({g:}),-{t:}/exp({h:}),-{rho}), ///
>                 binormal(-{y:}/exp({g:}),-{t:}/exp({h:}),{rho}) ///
>         )))), vce(sturdy)

preliminary:       log pseudolikelihood = -13862.944
various:   log pseudolikelihood = -16501.619
rescale:       log pseudolikelihood = -13858.877
rescale eq:    log pseudolikelihood = -11224.877
Iteration 0:   log pseudolikelihood = -11224.877  (not concave)
Iteration 1:   log pseudolikelihood = -10644.625  
Iteration 2:   log pseudolikelihood = -10074.998  
Iteration 3:   log pseudolikelihood = -9976.6027  
Iteration 4:   log pseudolikelihood = -9973.0988  
Iteration 5:   log pseudolikelihood = -9973.0913  
Iteration 6:   log pseudolikelihood = -9973.0913  

Most probability estimation

Log pseudolikelihood = -9973.0913               Variety of obs     =     10,000

------------------------------------------------------------------------------
             |               Strong
             |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
y            |
       t#c.x |
          0  |   .6178115   .0334521    18.47   0.000     .5522467    .6833764
          1  |   .2732094   .0365742     7.47   0.000     .2015253    .3448936
             |
           t |
          0  |  -.8403294   .1130197    -7.44   0.000    -1.061844   -.6188149
          1  |  -1.215177   .1837483    -6.61   0.000    -1.575317   -.8550371
-------------+----------------------------------------------------------------
g            |
           g |   .4993187   .0513297     9.73   0.000     .3987143    .5999232
-------------+----------------------------------------------------------------
t            |
           x |   .4985802   .0183033    27.24   0.000     .4627065    .5344539
           b |  -.1140255   .0132988    -8.57   0.000    -.1400908   -.0879603
           z |   .4993995   .0150844    33.11   0.000     .4698347    .5289643
       _cons |  -2.402772   .0780275   -30.79   0.000    -2.555703   -2.249841
-------------+----------------------------------------------------------------
h            |
           h |   .1011185   .0199762     5.06   0.000     .0619658    .1402713
-------------+----------------------------------------------------------------
        /rho |   .7036964   .0326734    21.54   0.000     .6396577    .7677351
------------------------------------------------------------------------------

Our parameter estimates are near their true values.

Estimating the ATE

The ATE of (t) is the anticipated worth of the distinction between (y_{1i}) and (y_{0i}), the common distinction between the potential outcomes. Utilizing the regulation of iterated expectations, we now have

[begin{eqnarray*}
E(y_{1i}-y_{0i})&=& Eleft{ Eleft(y_{1i}-y_{0i}|{bf x}_i,{bf w}_iright)right} cr
&=& EleftlbrackPhileft{frac{{bf x}_i{boldsymbol beta}_1}{
expleft({bf w}_i{boldsymbol gamma}right)}right}-
Phileft{frac{{bf x}_i{boldsymbol beta}_0}{
expleft({bf w}_i{boldsymbol gamma}right)}right}rightrbrack cr
end{eqnarray*}]

This may be estimated as a imply of predictions.

Now, we estimate the ATE by utilizing margins. We specify the conventional chance expression within the expression() possibility. We use the expression operate xb() to get the linear predictions for the end result equation and the end result error variance equation. We are able to now predict these linear kinds after mlexp in Stata 14.1. We specify r.t in order that margins will take the distinction of the expression underneath t=1 and t=0. We specify vce(unconditional) to acquire customary errors for the inhabitants ATE moderately than the pattern ATE; we specified vce(sturdy) for mlexp in order that we may specify vce(unconditional) for margins. The distinction(nowald) possibility is specified to omit the Wald take a look at for the distinction.


. margins r.t, expression(regular(xb(y)/exp(xb(g)))) ///
>     vce(unconditional) distinction(nowald)

Contrasts of predictive margins

Expression   : regular(xb(y)/exp(xb(g)))

--------------------------------------------------------------
             |            Unconditional
             |   Distinction   Std. Err.     [95% Conf. Interval]
-------------+------------------------------------------------
           t |
   (1 vs 0)  |  -.4183043   .0202635     -.4580202   -.3785885
--------------------------------------------------------------

We estimate that the ATE of (t) on (y) is (-0.42). So taking the remedy decreases the chance of a optimistic consequence by (0.42) on common over the inhabitants.

We’ll examine this estimate to the common distinction of (y_{1}) and (y_{0}) within the pattern. We are able to do that as a result of we simulated the info. In observe, just one potential consequence is noticed for each statement, and this common distinction can’t be computed.


. generate diff = y1 - y0

. sum diff

    Variable |        Obs        Imply    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
        diff |     10,000      -.4164    .5506736         -1          1

In our pattern, the common distinction of (y_{1}) and (y_{0}) can be (-0.42).

Conclusion

I’ve demonstrated methods to estimate the parameters of a mannequin that isn’t accessible in Stata: the heteroskedastic probit mannequin with an endogenous remedy utilizing mlexp. See [R] mlexp for extra particulars about mlexp. I’ve additionally demonstrated methods to use margins to estimate the ATE for the heteroskedastic probit mannequin with an endogenous remedy. See [R] margins for extra particulars about mlexp.

Reference

Harvey, A. C. 1976. Estimating regression fashions with multiplicative heteroscedasticity. Econometrica 44: 461-465.



Related Articles

Latest Articles