# Re: st: Replicating a sas loop in stata results in very slow computation time....

 From "Scott Merryman" To statalist@hsphsun2.harvard.edu Subject Re: st: Replicating a sas loop in stata results in very slow computation time.... Date Thu, 10 Apr 2008 14:52:27 -0500

```How long in Stata does it take to perform estimate one -logit- model?

A couple points on your SAS code.  You are using probability weights
in your Stata code but SAS is using frequency weights.  Using the
Stata auto data set the following code SAS returns:

1178    proc logistic data=auto  descending;
1179   class foreign ;
1180   model foreign =mpg ;
1181    weight price;
1182    run;

Analysis of Maximum Likelihood Estimates

Standard          Wald
Parameter    DF    Estimate       Error    Chi-Square
Pr > ChiSq

Intercept     1     -3.8587      0.0143    73208.6299
<.0001
mpg           1      0.1478    0.000661    50063.9741
<.0001

which is equivalent to the Stata code

. logit fore mpg  [fw = price], nolog

Logistic regression                               Number of obs   =     456229
LR chi2(1)      =   61231.77
Prob > chi2     =     0.0000
Log likelihood = -251056.48                       Pseudo R2       =     0.1087

------------------------------------------------------------------------------
foreign |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
mpg |   .1478456   .0006608   223.75   0.000     .1465505    .1491407
_cons |  -3.858749   .0142614  -270.57   0.000      -3.8867   -3.830797
------------------------------------------------------------------------------
r; t=0.05 14:31:39

I don't know if changing the weights this will make your code run faster.

Also, the default technique in SAS is IRLS.  Stata uses Newton-Raphson.
At least in a couple of examples, changing the technique to NR did
increase the time.

```