Announcement

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

  • Conformability error with margins after repost with buildfvinfo

    Hi,

    I am writing a bespoke estimation that uses clogit as a base. After running clogit I modify the e(b) and e(V) matrices and use ereturn repost . If I include the option buildfvinfo when I repost the matrices, the margins postestimation command no longer works and returns "conformability error; r(503);".
    I have checked this in a very straightforward setting using clogit and ologit, where I do not modify the b and V matrices but simply copy and repost them. Without the buildfvinfo option it works fine, but with it margins breaks. Any advice would be much appreciated.

    Cheers,
    -Alex


    Code:
    //Test eret repost do file
    clear all
    set more off
    
    use http://www.stata-press.com/data/r13/clogitid
    
    clogit y x1 x2, group(id)
    margins, dydx(*) predict(pu0)
    
    eretswap
    
    margins, dydx(*) predict(pu0)
    
    end
    Code:
    // Program to copy and repost e(b) and e(V)
    program eretswap, eclass
        syntax [, *]
    
    mat tempb = e(b)
    mat tempV = e(V)
    
    eret repost b=tempb V=tempV, buildfvinfo
    
    end




  • #2
    Some further investigations have found that the internal matrix H changes dimension after the ereturn repost command. If the H matrix after the initial estimation is dimension MxM, after reposting it is (M-1)x(M-1). In addition, if I use factor variable notation on x1 (i.e. clogit y i.x1 x, group(id) ), not only does the dimension of H change, but the contents also contains elements that are not -1,0,1.

    Hopefully this additional information is useful in isolating the problem.

    Comment


    • #3
      To make this work, Alex can add the undocumented ADDCONS (sic) option to ereturn repost. Here is a modified version of his code

      Code:
      . // Program to copy and repost e(b) and e(V)
      . program eretswap, eclass
        1.         syntax [, *]
        2.         mat tempb = e(b)
        3.         mat tempV = e(V)
        4.         eret repost b=tempb V=tempV, buildfvinfo ADDCONS
        5. end
      
      . 
      . // Program to copy and repost e(b) and e(V)
      . use http://www.stata-press.com/data/r13/clogitid
      
      . clogit y x1 x2, group(id)
      note: multiple positive outcomes within groups encountered.
      
      Iteration 0:   log likelihood = -123.42828  
      Iteration 1:   log likelihood = -123.41386  
      Iteration 2:   log likelihood = -123.41386  
      
      Conditional (fixed-effects) logistic regression
      
                                                      Number of obs     =        369
                                                      LR chi2(2)        =       9.07
                                                      Prob > chi2       =     0.0107
      Log likelihood = -123.41386                     Pseudo R2         =     0.0355
      
      ------------------------------------------------------------------------------
                 y |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
      -------------+----------------------------------------------------------------
                x1 |    .653363   .2875215     2.27   0.023     .0898312    1.216895
                x2 |   .0659169   .0449555     1.47   0.143    -.0221943    .1540281
      ------------------------------------------------------------------------------
      
      . margins, dydx(*) predict(pu0)
      
      Average marginal effects                        Number of obs     =        369
      Model VCE    : OIM
      
      Expression   : Pr(y|fixed effect is 0), predict(pu0)
      dy/dx w.r.t. : x1 x2
      
      ------------------------------------------------------------------------------
                   |            Delta-method
                   |      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
      -------------+----------------------------------------------------------------
                x1 |   .1465753   .0625489     2.34   0.019     .0239817     .269169
                x2 |   .0147878   .0090277     1.64   0.101    -.0029061    .0324817
      ------------------------------------------------------------------------------
      
      . eretswap
      
      . margins, dydx(*) predict(pu0)
      
      Average marginal effects                        Number of obs     =        369
      Model VCE    : OIM
      
      Expression   : Pr(y|fixed effect is 0), predict(pu0)
      dy/dx w.r.t. : x1 x2
      
      ------------------------------------------------------------------------------
                   |            Delta-method
                   |      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
      -------------+----------------------------------------------------------------
                x1 |   .1465753   .0625489     2.34   0.019     .0239817     .269169
                x2 |   .0147878   .0090277     1.64   0.101    -.0029061    .0324817
      ------------------------------------------------------------------------------
      Joerg

      Comment

      Working...
      X