Announcement

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

  • mediate command for 2 mediators

    Hello!

    I am learning to use the "mediate" command with one and two mediators. There is no issue with the command when it is one mediator. However, with two mediators, the command returns an invalid model specification. Here are the data, command, and material I am using and learning from:

    Data source: https://www.stata-press.com/data/r19/qoflife
    Command: mediate (hrqol) (depress) (physact) (arthritis)
    Documentation: STATA CAUSAL INFERENCE AND TREATMENT-EFFECTS ESTIMATION REFERENCE MANUAL RELEASE 19 ( code and data at page 393)

    I use STATA SE version 19 on a MacBook Air.

    Has anyone tried the command and experienced this issue?


    Thanks for your help, and Happy New Year 2026!!

    Kevin


    Last edited by Thierry Affoukou; 01 Jan 2026, 16:23.

  • #2
    I have played with the command and not had any issue; I have StataNow 19.5; what version are you using? what, exactly, did Stata return when you tried this?

    note that clicking on your link gives a "404 page not found" on my system

    Comment


    • #3
      Originally posted by Rich Goldstein View Post
      I have played with the command and not had any issue; I have StataNow 19.5; what version are you using? what, exactly, did Stata return when you tried this?

      note that clicking on your link gives a "404 page not found" on my system
      I also get a 404. But searching for "qoflife" on that page took me to this page. I think this is the data file that was referred to: Cheers,
      Bruce
      --
      Bruce Weaver
      Email: [email protected]
      Version: Stata/MP 19.5 (Windows)

      Comment


      • #4
        Originally posted by Rich Goldstein View Post
        I have played with the command and not had any issue; I have StataNow 19.5; what version are you using? what, exactly, did Stata return when you tried this?

        note that clicking on your link gives a "404 page not found" on my system
        Hi Rich,
        Thank you for your reply. Unfortunately, I do not have StataNow because I have an Unlimited-user license. That might be my issue. Here is what I get when I run the command:
        load data: use https://www.stata-press.com/data/r19/wellbeing
        command: mediate (hrqol) (depress) (physact) (arthritis)
        In the model, the variables depress and physact are the mediator, hrqol is the outcome variable, and arthritis is the treatment variable.

        Error: invalid model specification
        Specification must consist of a model for the outcome, a model for the mediator, and the treatment variable. r(198);
        Click image for larger version

Name:	Stata Error.png
Views:	1
Size:	27.0 KB
ID:	1784076



        Here is the error attached as a picture.

        Thank you
        Last edited by Thierry Affoukou; 04 Jan 2026, 15:39.

        Comment


        • #5
          Originally posted by Bruce Weaver View Post

          I also get a 404. But searching for "qoflife" on that page took me to this page. I think this is the data file that was referred to: Cheers,
          Bruce
          Thank you, Bruce. I forgot to include the data extension.

          Comment


          • #6
            you still don't say what version you are using but clearly if you want to estimate a model with 2 mediators (either parallel or serial) you will need to use sem/gsem or basic regression commands (depending on what your actual data look like - as -mediate- w/2 mediators will not run on your version

            Comment


            • #7
              Hello I am having the same problem. When I run: mediate (hrqol) (depress) (physact) (arthritis), I get: invalid model specification. Specification must consist of a model for the outcome, a model for the mediator, and the treatment variable. r(198);
              I have StataNow/BE 19.5 for Windows (64-bit x86-64).

              Comment


              • #8
                Originally posted by AL MURR View Post
                Hello I am having the same problem. When I run: mediate (hrqol) (depress) (physact) (arthritis), I get: invalid model specification. Specification must consist of a model for the outcome, a model for the mediator, and the treatment variable. r(198);
                I have StataNow/BE 19.5 for Windows (64-bit x86-64).
                I just needed an update. It is working now

                Comment

                Working...
                X