Announcement

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

  • margins, saving(), and test

    Hello, I am using multilevel logistic regression (melogit) in a large data set (1/2 million observations). margins takes a long time to run after melogit.

    Thanks to this forum, I know that margins has an undocumented saving() option. I also know that marginsplot can "use" those stored results.

    However, is there a way to load the saved margins results so that I can use them with a test command?

    Here is a short example.

    Code:
    use http://www.stata-press.com/data/r15/margex, clear
    
    logit outcome sex##c.age i.group
    
    margins sex, at(age = (20 30 40 50 60)) saving(mymargins.dta, replace)
    
    marginsplot using mymargins.dta // works
    Is there a way to use the "test" command with the saved margins to test different margins against each other?

    Thank you very much for any thoughts you might have.

  • #2
    You can post the output of margins and the VCE as an estimation result, save it, and then open it later to produce the plot and conduct the hypothesis test:

    Code:
    use http://www.stata-press.com/data/r15/margex, clear
    logit outcome sex##c.age i.group
    margins sex, at(age = (20 30 40 50 60)) post // coefl
    estimates save "sex_margins.dta", replace
    estimates clear
    estimates use "sex_margins.dta"
    marginsplot
    test _b[1._at#0.sex] =  _b[2._at#0.sex]

    Comment


    • #3
      Thanks! Super helpful. I appreciate this. Will be trying it out over the weekend, or next week. -Andy

      Comment

      Working...
      X