Announcement

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

  • Syntaxproblem with mi test

    Dear Statalister,
    I want to compare two groups ((0.hsgrad+1.hsgrad) vs. 2.hsgrad) after mvreg.
    The syntax for the not imputed dataset works fine.
    If I want to replicate the same with an imputed dataset, the following error message is displayed:

    . mi test (0.hsgrad+1.hsgrad)/2 = 2.hsgrad
    =exp not allowed
    r(101);

    What is my fault?


    Code:
    use http://www.stata-press.com/data/r13/mheart1s20, clear
     
    preserve
    mi extract 5
    replace hsgrad=2 if smokes==1
    mvreg  bmi  = female##hsgrad
    margins , predict(equation(bmi)) dydx(hsgrad ) asbalanced post
    test (0.hsgrad+1.hsgrad)/2 = 2.hsgrad
    esizei `=r(df)' `=r(df_r)' `=r(F)'
    
    restore
    
    replace hsgrad=2 if smokes==1
    mi estimate : mvreg  bmi = female##hsgrad
    mimrgns , predict(equation(bmi)) dydx(hsgrad ) asbalanced post
    mi test (0.hsgrad+1.hsgrad)/2 = 2.hsgrad

  • #2
    In your non-imputed model, you are testing results posted by the margins command, not results directly obtained from mvreg. In the imputed case, you are trying to replicate that with mimrgns (community-contributed, probably from SSC as you are asked to explain). Here, you assume that you need mi test, that mi test would technically work with mimrgns, and that mi test after mimrgns would give correct results.

    Concerning the latter two assumptions, the help for mimrgns states that

    mimrgns does not save all results that margins saves. This might lead to error messages when running post
    estimation commands, e.g. mi test. Even if no error messages appear, such results might not be appropriate.
    Concerning the first assumption, I believe you need mi testtransform. Here is a sketch of how to obtain what I believe you want. I cannot guarantee that those results are valid. Further, if you want those effect sizes, you need to make sure to grab the correct df and F values; I have not looked into that.

    Code:
    program mymitest , eclass properties(mi)
        mvreg  bmi  = female##hsgrad
        margins , predict(equation(bmi)) dydx(hsgrad ) asbalanced post
    end
    
    mi estimate (totest: (_b[0.hsgrad]+_b[1.hsgrad])/2-_b[2.hsgrad]) : ///
        mymitest foo
    mi testtransform totest
    Best
    Daniel

    Comment


    • #3
      Dear Daniel,
      Thank you so much. It works.
      Best regards,
      Jörg

      Comment

      Working...
      X