Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error when using "margins" command

    I have used the "margins" command successfully earlier, but now run into an error every time I try to employ it. I use Stata 16.

    As an example, this happens when I try to reproduce the first example given in the margins help file:

    Code:
    . webuse margex, clear
    (Artificial data for margins)
    
    . regress y i.sex i.group
    
          Source |       SS           df       MS      Number of obs   =     3,000
    -------------+----------------------------------   F(3, 2996)      =    152.06
           Model |  183866.077         3  61288.6923   Prob > F        =    0.0000
        Residual |  1207566.93     2,996  403.059723   R-squared       =    0.1321
    -------------+----------------------------------   Adj R-squared   =    0.1313
           Total |  1391433.01     2,999  463.965657   Root MSE        =    20.076
    
    ------------------------------------------------------------------------------
               y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
             sex |
         female  |   18.32202   .8930951    20.52   0.000     16.57088    20.07316
                 |
           group |
              2  |   8.037615    .913769     8.80   0.000     6.245937    9.829293
              3  |   18.63922   1.159503    16.08   0.000     16.36572    20.91272
                 |
           _cons |   53.32146   .9345465    57.06   0.000     51.48904    55.15388
    ------------------------------------------------------------------------------
    
    .
    . margins sex
    invalid syntax
    r(198);
    Stata gives the same error every time I use the margins command.

    Experience tells me that Stata is right and I did something wrong when something is not working, but I struggle to see any errors here. Any idea what is going on?

  • #2
    Code:
    . about
    
    Stata/MP 16.0 for Windows (64-bit x86-64)
    Revision 14 Nov 2019
    Copyright 1985-2019 StataCorp LLC
    
    Total physical memory:       32.00 GB
    Available physical memory:   22.51 GB
    
    Single-user 4-core Stata perpetual license:
           Serial number:  REDACTED
             Licensed to:  Clyde Schechter
                           Albert Einstein College of Medicine
    
    .
    . webuse margex, clear
    (Artificial data for margins)
    
    .
    . regress y i.sex i.group
    
          Source |       SS           df       MS      Number of obs   =     3,000
    -------------+----------------------------------   F(3, 2996)      =    152.06
           Model |  183866.077         3  61288.6923   Prob > F        =    0.0000
        Residual |  1207566.93     2,996  403.059723   R-squared       =    0.1321
    -------------+----------------------------------   Adj R-squared   =    0.1313
           Total |  1391433.01     2,999  463.965657   Root MSE        =    20.076
    
    ------------------------------------------------------------------------------
               y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
             sex |
         female  |   18.32202   .8930951    20.52   0.000     16.57088    20.07316
                 |
           group |
              2  |   8.037615    .913769     8.80   0.000     6.245937    9.829293
              3  |   18.63922   1.159503    16.08   0.000     16.36572    20.91272
                 |
           _cons |   53.32146   .9345465    57.06   0.000     51.48904    55.15388
    ------------------------------------------------------------------------------
    
    .
    . margins sex
    
    Predictive margins                              Number of obs     =      3,000
    Model VCE    : OLS
    
    Expression   : Linear prediction, predict()
    
    ------------------------------------------------------------------------------
                 |            Delta-method
                 |     Margin   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
             sex |
           male  |   60.56034   .5781782   104.74   0.000     59.42668    61.69401
         female  |   78.88236   .5772578   136.65   0.000      77.7505    80.01422
    ------------------------------------------------------------------------------
    I cannot replicate your difficulty on my setup. Here are a few suggestions to try:

    1. Run -update all, force- to make sure you have a complete installation of the most recent Stata version 16.
    2. If that does not help, reboot your computer and try the code again.
    3. If that still does not help, I suggest contacting Stata technical support about this. When doing this, be sure to provide complete information about your setup (OS, make and model of hardware).

    Comment


    • #3
      Thanks for the swift reply!
      Rebooting did not help. I need an admin to update Stata. I will contact support if updating does not help.

      Comment

      Working...
      X