Differences between revisions 1 and 3 (spanning 2 versions)
Revision 1 as of 2023-03-15 21:13:08
Size: 350
Comment:
Revision 3 as of 2024-04-25 16:58:24
Size: 2354
Comment: Phrasing update
Deletions are marked like this. Additions are marked like this.
Line 2: Line 2:

The '''`logit`''' command runs a logistic regression.
Line 11: Line 13:
Copied from [[https://stats.idre.ucla.edu/stata/dae/logistic-regression/|here]]:
Line 12: Line 16:
logit dependent independent . use https://stats.idre.ucla.edu/stat/stata/dae/binary, clear

. logit admit gre gpa i.rank

Iteration 0: log likelihood = -249.98826
Iteration 1: log likelihood = -229.66446
Iteration 2: log likelihood = -229.25955
Iteration 3: log likelihood = -229.25875
Iteration 4: log likelihood = -229.25875

Logistic regression Number of obs = 400
                                                  LR chi2(5) = 41.46
                                                  Prob > chi2 = 0.0000
Log likelihood = -229.25875 Pseudo R2 = 0.0829

------------------------------------------------------------------------------
       admit | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
         gre | .0022644 .001094 2.07 0.038 .0001202 .0044086
         gpa | .8040377 .3318193 2.42 0.015 .1536838 1.454392
             |
        rank |
          2 | -.6754429 .3164897 -2.13 0.033 -1.295751 -.0551346
          3 | -1.340204 .3453064 -3.88 0.000 -2.016992 -.6634158
          4 | -1.551464 .4178316 -3.71 0.000 -2.370399 -.7325287
             |
       _cons | -3.989979 1.139951 -3.50 0.000 -6.224242 -1.755717
------------------------------------------------------------------------------
Line 15: Line 46:
Compare the output of [[Stata/Logistic|logistic]], which always shows the odds ratios, while the `or` option must be specified on `logit` to show those.
Line 16: Line 49:

----



== Estimates ==

The estimates can be accessed through any of the following commands...
 * `predict` creates a variable storing the predicted probability for each case
 * `margins` displays the marginal predicted probabilities

Stata Logit

The logit command runs a logistic regression.


Usage

Copied from here:

. use https://stats.idre.ucla.edu/stat/stata/dae/binary, clear

. logit admit gre gpa i.rank

Iteration 0:   log likelihood = -249.98826
Iteration 1:   log likelihood = -229.66446
Iteration 2:   log likelihood = -229.25955
Iteration 3:   log likelihood = -229.25875
Iteration 4:   log likelihood = -229.25875

Logistic regression                               Number of obs   =        400
                                                  LR chi2(5)      =      41.46
                                                  Prob > chi2     =     0.0000
Log likelihood = -229.25875                       Pseudo R2       =     0.0829

------------------------------------------------------------------------------
       admit |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         gre |   .0022644    .001094     2.07   0.038     .0001202    .0044086
         gpa |   .8040377   .3318193     2.42   0.015     .1536838    1.454392
             |
        rank |
          2  |  -.6754429   .3164897    -2.13   0.033    -1.295751   -.0551346
          3  |  -1.340204   .3453064    -3.88   0.000    -2.016992   -.6634158
          4  |  -1.551464   .4178316    -3.71   0.000    -2.370399   -.7325287
             |
       _cons |  -3.989979   1.139951    -3.50   0.000    -6.224242   -1.755717
------------------------------------------------------------------------------

Compare the output of logistic, which always shows the odds ratios, while the or option must be specified on logit to show those.

See here for details on factor variables.


Estimates

The estimates can be accessed through any of the following commands...

  • predict creates a variable storing the predicted probability for each case

  • margins displays the marginal predicted probabilities


See also

Stata manual for logit post-estimation


CategoryRicottone

Stata/Logit (last edited 2025-04-04 00:28:12 by DominicRicottone)