Announcement

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

  • margins with vce(unconditional) for svy data

    Hi,

    I ran a svy: glm model and now i am trying to estimate the margins. As you know since I am using svyset data file and svy: glm model, the margins command should be vce(unconditional) if the estimation model is linearized. now my questions is:
    1. i have got the margins once with vce(unconditional) and once without as shown below and the margins are the same though the CI are different. So would it be ok if i don't specify vce(unconditional)

    Code:
    . margins W1ethgrpYP, vce(unconditional)
    
    Predictive margins                              Number of obs      =      1664
    
    Expression   : Predicted mean KS4_PTSTNEWG, predict()
    
    ------------------------------------------------------------------------------
                 |             Linearized
                 |     Margin   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
      W1ethgrpYP |
              1  |   396.4839   6.955229    57.01   0.000     382.7473    410.2204
              2  |   440.4226   24.78977    17.77   0.000     391.4629    489.3823
              3  |   479.1828   47.64378    10.06   0.000     385.0865    573.2791
              4  |   428.8674    36.8949    11.62   0.000     356.0001    501.7347
              5  |   436.0725   45.21273     9.64   0.000     346.7775    525.3675
              6  |   440.0247   39.66395    11.09   0.000     361.6886    518.3609
              7  |   474.1615   27.91923    16.98   0.000     419.0211    529.3019
              8  |   445.8941   49.03087     9.09   0.000     349.0583    542.7299
    ------------------------------------------------------------------------------
    
    . margins W1ethgrpYP
    
    Predictive margins                                Number of obs   =       1664
    Model VCE    : Linearized
    
    Expression   : Predicted mean KS4_PTSTNEWG, predict()
    
    ------------------------------------------------------------------------------
                 |            Delta-method
                 |     Margin   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
      W1ethgrpYP |
              1  |   396.4839   4.771013    83.10   0.000     387.1329    405.8349
              2  |   440.4226    25.2624    17.43   0.000     390.9092     489.936
              3  |   479.1828   47.93554    10.00   0.000     385.2309    573.1347
              4  |   428.8674   36.97941    11.60   0.000     356.3891    501.3457
              5  |   436.0725   45.59635     9.56   0.000     346.7053    525.4397
              6  |   440.0247   40.32042    10.91   0.000     360.9982    519.0513
              7  |   474.1615   28.99045    16.36   0.000     417.3413    530.9817
              8  |   445.8941   48.61035     9.17   0.000     350.6196    541.1686
    ------------------------------------------------------------------------------
    2. I also tried to get the margins for a continuous variable with vce(unconditional) and it did not work but when i did not specify vce(unconditional) it worked with the default delta method. So why is that? and is it ok then to drop the vce(unconditional)?

    Code:
    . margins at((p25) KS4_CVAP3APS_Z )  at((p50) KS4_CVAP3APS_Z )  at((p75) KS4_CVAP3APS_Z ) , vce(unconditional)
    variable at not found
    r(111);
    
    . margins, at((p25) KS4_CVAP3APS_Z)  at((p50) KS4_CVAP3APS_Z)  at((p75) KS4_CVAP3APS_Z)
    
    Predictive margins                                Number of obs   =       1664
    Model VCE    : Linearized
    
    Expression   : Predicted mean KS4_PTSTNEWG, predict()
    
    1._at        : KS4_CVAP3A~Z    =   -.1484548 (p25)
    
    2._at        : KS4_CVAP3A~Z    =    .4140617 (p50)
    
    3._at        : KS4_CVAP3A~Z    =    .9943422 (p75)
    
    ------------------------------------------------------------------------------
                 |            Delta-method
                 |     Margin   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
             _at |
              1  |   324.7706   6.300149    51.55   0.000     312.4226    337.1187
              2  |   389.7903   4.170021    93.47   0.000     381.6173    397.9634
              3  |    470.531   6.681251    70.43   0.000      457.436     483.626
    ------------------------------------------------------------------------------
    I would appreciate any positive response soon.

    Thx
    Amira

  • #2
    Checking the position of the comma in your syntax should clarify 2.

    Best
    Daniel

    Comment


    • #3
      Thx a lot Daniel

      Comment


      • #4
        just an update:

        I am trying to calculate the marginal effects once using dy/dx and then ey/dx for a var and the output looks like that

        Code:
        . . margins, dydx( W1ethgrpYP)  vce(unconditional)
        
        Average marginal effects                        Number of obs      =      1664
        
        Expression   : Predicted mean KS4_PTSTNEWG, predict()
        dy/dx w.r.t. : 2.W1ethgrpYP 3.W1ethgrpYP 4.W1ethgrpYP 5.W1ethgrpYP 6.W1ethgrpYP 7.W1ethgrpYP
                       8.W1ethgrpYP
        
        ------------------------------------------------------------------------------
                     |             Linearized
                     |      dy/dx   Std. Err.      t    P>|t|     [95% Conf. Interval]
        -------------+----------------------------------------------------------------
          W1ethgrpYP |
                  2  |   43.93869   26.21764     1.68   0.096    -7.841051    95.71843
                  3  |    82.6989   49.85504     1.66   0.099    -15.76462    181.1624
                  4  |   32.38353   38.06412     0.85   0.396    -42.79296      107.56
                  5  |    39.5886   46.52603     0.85   0.396    -52.30013    131.4773
                  6  |   43.54086   40.88949     1.06   0.289    -37.21572    124.2974
                  7  |   77.67762   29.24172     2.66   0.009     19.92534    135.4299
                  8  |   49.41021   50.29439     0.98   0.327    -49.92102    148.7414
        ------------------------------------------------------------------------------
        Note: dy/dx for factor levels is the discrete change from the base level.
        
        
        margins, eydx( W1ethgrpYP)  vce(unconditional)
        
        Average marginal effects                        Number of obs      =      1664
        
        Expression   : Predicted mean KS4_PTSTNEWG, predict()
        ey/dx w.r.t. : 2.W1ethgrpYP 3.W1ethgrpYP 4.W1ethgrpYP 5.W1ethgrpYP 6.W1ethgrpYP 7.W1ethgrpYP
                       8.W1ethgrpYP
        
        ------------------------------------------------------------------------------
                     |             Linearized
                     |      ey/dx   Std. Err.      t    P>|t|     [95% Conf. Interval]
        -------------+----------------------------------------------------------------
          W1ethgrpYP |
                  2  |   .1050993   .0601327     1.75   0.082    -.0136625    .2238611
                  3  |   .1894467   .1052314     1.80   0.074    -.0183849    .3972784
                  4  |   .0785124   .0891044     0.88   0.380    -.0974685    .2544934
                  5  |   .0951731   .1071199     0.89   0.376    -.1163883    .3067344
                  6  |   .1041956   .0933894     1.12   0.266    -.0802481    .2886393
                  7  |   .1789126   .0626061     2.86   0.005     .0552658    .3025594
                  8  |   .1174461   .1132932     1.04   0.301    -.1063076    .3411998
        ------------------------------------------------------------------------------
        Note: ey/dx for factor levels is the discrete change from the base level.
        now when i want to check the marginal effect dy/dx with at() the output looks like that

        Code:
        . margins, dydx( W1ethgrpYP) at(  KS4_AGE_START=(14 15 16)) vce(unconditional)
        
        Average marginal effects                        Number of obs      =      1664
        
        Expression   : Predicted mean KS4_PTSTNEWG, predict()
        dy/dx w.r.t. : 2.W1ethgrpYP 3.W1ethgrpYP 4.W1ethgrpYP 5.W1ethgrpYP 6.W1ethgrpYP 7.W1ethgrpYP
                       8.W1ethgrpYP
        
        1._at        : KS4_AGE_ST~T    =          14
        
        2._at        : KS4_AGE_ST~T    =          15
        
        3._at        : KS4_AGE_ST~T    =          16
        
        -------------------------------------------------------------------------------
                      |             Linearized
                      |      dy/dx   Std. Err.      t    P>|t|     [95% Conf. Interval]
        --------------+----------------------------------------------------------------
        2.W1ethgrpYP  |
                  _at |
                   1  |   94.30087   55.12187     1.71   0.089    -14.56462    203.1664
                   2  |   43.94301   26.21815     1.68   0.096    -7.837734    95.72376
                   3  |   20.47689   12.87098     1.59   0.114    -4.943248    45.89702
        --------------+----------------------------------------------------------------
        3.W1ethgrpYP  |
                  _at |
                   1  |   177.4877   105.7226     1.68   0.095    -31.31395    386.2894
                   2  |   82.70703   49.85935     1.66   0.099    -15.76499    181.1791
                   3  |   38.54043    24.2785     1.59   0.114    -9.409517    86.49038
        --------------+----------------------------------------------------------------
        4.W1ethgrpYP  |
                  _at |
                   1  |   69.50128   79.67756     0.87   0.384     -87.8616    226.8642
                   2  |   32.38671   38.06607     0.85   0.396    -42.79363    107.5671
                   3  |    15.0918   18.31947     0.82   0.411    -21.08909    51.27268
        --------------+----------------------------------------------------------------
        5.W1ethgrpYP  |
                  _at |
                   1  |   84.96473   97.46516     0.87   0.385    -107.5286    277.4581
                   2  |   39.59249   46.52817     0.85   0.396    -52.30047    131.4854
                   3  |    18.4496   22.37651     0.82   0.411    -25.74392    62.64311
        --------------+----------------------------------------------------------------
        6.W1ethgrpYP  |
                  _at |
                   1  |   93.44705   88.37334     1.06   0.292    -81.08996    267.9841
                   2  |   43.54514   40.89368     1.06   0.289    -37.21973      124.31
                   3  |   20.29148   19.18921     1.06   0.292    -17.60713     58.1901
        --------------+----------------------------------------------------------------
        7.W1ethgrpYP  |
                  _at |
                   1  |   166.7111   62.91799     2.65   0.009     42.44831    290.9739
                   2  |   77.68526    29.2452     2.66   0.009      19.9261    135.4444
                   3  |   36.20035   14.74084     2.46   0.015     7.087247    65.31345
        --------------+----------------------------------------------------------------
        8.W1ethgrpYP  |
                  _at |
                   1  |   106.0438   108.5797     0.98   0.330    -108.4008    320.4884
                   2  |   49.41507   50.29994     0.98   0.327    -49.92711    148.7573
                   3  |    23.0268   23.58058     0.98   0.330    -23.54476    69.59835
        -------------------------------------------------------------------------------
        Note: dy/dx for factor levels is the discrete change from the base level.
        but when calculating the marginal effect ey/dx with at(), the output looks like the original ey/dx repeated over each level in at():

        Code:
        . margins, eydx( W1ethgrpYP) at(  KS4_AGE_START=(14 15 16)) vce(unconditional)
        
        Average marginal effects                        Number of obs      =      1664
        
        Expression   : Predicted mean KS4_PTSTNEWG, predict()
        ey/dx w.r.t. : 2.W1ethgrpYP 3.W1ethgrpYP 4.W1ethgrpYP 5.W1ethgrpYP 6.W1ethgrpYP 7.W1ethgrpYP
                       8.W1ethgrpYP
        
        1._at        : KS4_AGE_ST~T    =          14
        
        2._at        : KS4_AGE_ST~T    =          15
        
        3._at        : KS4_AGE_ST~T    =          16
        
        -------------------------------------------------------------------------------
                      |             Linearized
                      |      ey/dx   Std. Err.      t    P>|t|     [95% Conf. Interval]
        --------------+----------------------------------------------------------------
        2.W1ethgrpYP  |
                  _at |
                   1  |   .1050993   .0601327     1.75   0.082    -.0136625    .2238611
                   2  |   .1050993   .0601327     1.75   0.082    -.0136625    .2238611
                   3  |   .1050993   .0601327     1.75   0.082    -.0136625    .2238611
        --------------+----------------------------------------------------------------
        3.W1ethgrpYP  |
                  _at |
                   1  |   .1894467   .1052314     1.80   0.074    -.0183849    .3972784
                   2  |   .1894467   .1052314     1.80   0.074    -.0183849    .3972784
                   3  |   .1894467   .1052314     1.80   0.074    -.0183849    .3972784
        --------------+----------------------------------------------------------------
        4.W1ethgrpYP  |
                  _at |
                   1  |   .0785124   .0891044     0.88   0.380    -.0974685    .2544934
                   2  |   .0785124   .0891044     0.88   0.380    -.0974685    .2544934
                   3  |   .0785124   .0891044     0.88   0.380    -.0974685    .2544934
        --------------+----------------------------------------------------------------
        5.W1ethgrpYP  |
                  _at |
                   1  |   .0951731   .1071199     0.89   0.376    -.1163883    .3067344
                   2  |   .0951731   .1071199     0.89   0.376    -.1163883    .3067344
                   3  |   .0951731   .1071199     0.89   0.376    -.1163883    .3067344
        --------------+----------------------------------------------------------------
        6.W1ethgrpYP  |
                  _at |
                   1  |   .1041956   .0933894     1.12   0.266    -.0802481    .2886393
                   2  |   .1041956   .0933894     1.12   0.266    -.0802481    .2886393
                   3  |   .1041956   .0933894     1.12   0.266    -.0802481    .2886393
        --------------+----------------------------------------------------------------
        7.W1ethgrpYP  |
                  _at |
                   1  |   .1789126   .0626061     2.86   0.005     .0552658    .3025594
                   2  |   .1789126   .0626061     2.86   0.005     .0552658    .3025594
                   3  |   .1789126   .0626061     2.86   0.005     .0552658    .3025594
        --------------+----------------------------------------------------------------
        8.W1ethgrpYP  |
                  _at |
                   1  |   .1174461   .1132932     1.04   0.301    -.1063076    .3411998
                   2  |   .1174461   .1132932     1.04   0.301    -.1063076    .3411998
                   3  |   .1174461   .1132932     1.04   0.301    -.1063076    .3411998
        -------------------------------------------------------------------------------
        Note: ey/dx for factor levels is the discrete change from the base level.
        
        .
        can anyone help with why this is happening..i am confused.am i doing something wrong?

        thx
        amira

        Comment

        Working...
        X