Announcement

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

  • Saved mixed effects results into putdocx

    Hello STATA List users,

    I am performing a mixed effect model that models NfL (continuous) with Age (continuous) across multiple CAG repeat lengths (from 40-46) (ordinal continuous). The code that I am currently using is as follows:

    Code:
     summarize CAG if disease_grp==1, meanonly
            local min_cag = round(r(min))
            local max_cag = round(r(max))        
        
        forvalues e = `min_cag'/`max_cag' {
            summarize Age if CAG==`e' & disease_grp==1, meanonly
                local min = round(r(min))
                local max = round(r(max))
            mixed NfL c.Age c.CAG if disease_grp==1, stddeviations reml 
            margins, at(Age=(`min'(0.15)`max') CAG=`e') post
                        est store model_cag`e'
    I am trying to save the Mixed-effects REML regression table into a putdocx document but if I follow this code with 'putdocx table control = etable', it only puts the margins table. Is there a way I can get both tables into a word document?

    I look forward to your responses.
    Annabelle

  • #2
    I do not use putdocx, but it is clear that margins with the -post- option overwrites the estimates in memory. You need to call putdocx table immediately following the mixed command and then after margins. Then save the document at the end.

    Comment


    • #3
      Hello Andrew,

      Thank you for your response.

      I have tired entering the putdocx table command immediately following the mixed command and also after the margins command however I keep getting the same error. This is the code:
      Code:
      mixed NfL c.Age if disease_grp==0, stddeviations reml  
             est store mixed_control
            putdocx table control = etable
                margins, at(Age=(`min'(0.15)`max')) post 
                  est store model_control 
                                          
                                          putdocx paragraph, style(Heading4)
                                          putdocx text ("Estimation results fixed effect model NfL and Age in healthy controls.")
                                          putdocx table control = etable
      It doesn't run the margins, the error comes after running the mixed model. This is the error:
      Code:
      information for the estimation table not found;
          Please replay estimation results and try again
      r(111);
      
      end of do-file
      
      r(111);

      Comment


      • #4
        I would need a reproducible example to try out code. Try

        Code:
        help mixed
        to see if you can find a dataset that reproduces the issue.

        Comment

        Working...
        X