Announcement

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

  • Outreg2 user created function to export mediation tests like the suest command or the bootstrapping method of preacher and hayes?

    Hi, recently I found out that one could use the user created funciton called outreg2 to export regression outputs and descriptive statistics, too. But I am wondering if you can use the outreg2 user created function to export the output of a mediation test like suest or the bootstrapping/ Strobel-Goodman mediation test.

  • #2
    There is a possibility to use asdoc (can be installed from SSC) for exporting such statistics. See the following example:

    Code:
    ssc install asdoc // if not already installed
    webuse income
    probit promo edu exp
    estimates store Promo
    regress inc edu exp
    estimates store Inc
    suest Promo Inc
    asdoc suest Promo Inc
    Regards
    --------------------------------------------------
    Attaullah Shah, PhD.
    Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
    FinTechProfessor.com
    https://asdocx.com
    Check out my asdoc program, which sends outputs to MS Word.
    For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

    Comment


    • #3
      Thank you, Dr. Shah.

      I am getting this error message:

      asdoc sum hemoglobine indigenous smoker
      The current director is not writable!
      The current working directory is C:\windows\system32
      asdoc cannot write to this directory. As a solution,
      you can change to another directory with command cd
      For example, try creating a folder results in drive C:,
      change to that directory, and retry your asdoc command.

      mkdir c:/results

      cd c:/results

      asdoc sum hemoglobine indigenous smoker

      . cd c:/results
      unable to change to c:/results
      r(170);


      Can you please give me an example of how I can fix this?

      Comment


      • #4
        The message produced by asdoc is self-explanatory. It complains that the current directory is C:\windows\system32 which Stata cannot write to. Therefore, you need to create another directory on your PC and change the Stata current directory to that one. One solution is already provided by asdoc, that is:

        Code:
        * create a directory in C drive with the name results
        mkdir c:/results
        
        * change to that directory from Stata
        
        cd c:/results
        
        * and then apply asdoc command again
        asdoc sum hemoglobine indigenous smoker
        However, it seems that you have skipped the first two lines and directly clicked on the cd c:/results and Stata complained that it cannot change to this directory as it does not exist.
        Regards
        --------------------------------------------------
        Attaullah Shah, PhD.
        Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
        FinTechProfessor.com
        https://asdocx.com
        Check out my asdoc program, which sends outputs to MS Word.
        For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

        Comment


        • #5
          Thanks, Dr. Shah! I figured it out now and I appreciate your comments. Thanks.

          Comment


          • #6
            Dr. Shah,

            I have an error message about syntax. I followed your video about exporting a nested regression with asdoc, but I'm getting this error message still. I want to save a new file called RT with my nested regression (nestreg) with my model 1, model 2, and model 3 in the nestreg regression table. Can you please help me save a new file and why I'm getting this error message with trying to export my nested regression to a document file and how to fix this?

            code:

            asdoc reg hemoglobine indigenous smoker relationship spanish income age education gender employment, cluster (locid) nest save (RT)

            ouput:

            asdoc reg hemoglobine indigenous smoker relationship spanish income age education gender employment, cluster (locid) nest
            > save (RT)
            (File Myfile.doc already exists, option append was assumed)
            append(): 3200 conformability error
            <istmt>: - function returned error
            r(3200);

            Comment


            • #7
              When you run the command, try adding replace in the first run and then add append in all other runs. If you notice, in this YouTube video, I add replace in the first instance, i.e.

              Code:
              asdoc reg hemoglobine indigenous smoker relationship spanish income age education gender employment, cluster (locid) nest save (RT)  replace
              
              asdoc reg hemoglobine indigenous smoker relationship income age education gender employment, cluster (locid) nest save (RT)  append
              Last edited by Attaullah Shah; 14 Apr 2018, 23:50.
              Regards
              --------------------------------------------------
              Attaullah Shah, PhD.
              Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
              FinTechProfessor.com
              https://asdocx.com
              Check out my asdoc program, which sends outputs to MS Word.
              For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

              Comment


              • #8
                Hi, Dr. Shah:

                When I ran the first line of code you referenced, STATA said that the variable locid wasn't found. I am not sure why this is producing an error since asdoc is install.

                code:
                asdoc reg hemoglobine indigenous smoker relationship spanish income age education gender employment, cluster (locid) nest save (RT) replace

                output: . asdoc reg hemoglobine indigenous smoker relationship spanish income age education gender employment, cluster (locid) nest > save (RT) replace

                variable locid not found option ( not allowed r(198);

                Comment


                • #9
                  Roman Johnson, cluster(locid) is not part of asdoc command. This option belongs to regress command. Therefore, you do not need to add this to your regression line. IF you are following my video, then we used cluster(locid) to adjust regression errors for location id, where locidwas a variable in our data set.
                  Regards
                  --------------------------------------------------
                  Attaullah Shah, PhD.
                  Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
                  FinTechProfessor.com
                  https://asdocx.com
                  Check out my asdoc program, which sends outputs to MS Word.
                  For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

                  Comment


                  • #10
                    Thanks for your help thus far, but I still am getting the same error message. I removed cluster (locid) from the statement and have been following your YouTube video on this subject. I am not sure why it is still not working. MyFile.doc is a read file and I can not even save it elsewhere to do what I want.

                    Here is my code:

                    asdoc sum hemoglobine indigenous smoker relationship spanish income age education gender employment, save (descriptives.doc)



                    output:


                    . asdoc reg hemoglobine indigenous smoker relationship spanish income age education gender employment, nest save (descriptiv
                    > es.doc)
                    (File Myfile.doc already exists, option append was assumed)
                    append(): 3200 conformability error
                    <istmt>: - function returned error
                    r(3200);

                    Comment


                    • #11
                      Roman Johnson, this takes us back to the original problem to which I replied in my post #7 above. I can see that you have not used replace in the first run of the program. When you use option nest, you have to use replace in the first run of the program. Therefore, your command should be
                      Code:
                      asdoc reg hemoglobine indigenous smoker relationship spanish income age education gender employment, nest save (descriptives.doc) replace
                      Last edited by Attaullah Shah; 16 Apr 2018, 08:04.
                      Regards
                      --------------------------------------------------
                      Attaullah Shah, PhD.
                      Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
                      FinTechProfessor.com
                      https://asdocx.com
                      Check out my asdoc program, which sends outputs to MS Word.
                      For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

                      Comment


                      • #12
                        Hi, Dr. Shah:

                        I have entered the code as you prescribed by stata is saying that parenthesis are not a part of proper asdoc syntax.

                        code:

                        asdoc reg hemoglobine indigenous smoker relationship spanish income age gender employment, nest save (descriptives.doc), replace

                        output:
                        . do "C:\Users\rjohn123\AppData\Local\Temp\STD1730_0000 00.tmp"

                        . asdoc reg hemoglobine indigenous smoker relationship spanish income age gender employment, nest save (descriptives.doc),
                        > replace
                        option ( not allowed
                        r(198);

                        end of do-file

                        Comment


                        • #13
                          There is uninteded space between these two words, save (descriptives.doc), The following command should work.

                          asdoc reg hemoglobine indigenous smoker relationship spanish income age gender employment, nest save(descriptives.doc), replace
                          Regards
                          --------------------------------------------------
                          Attaullah Shah, PhD.
                          Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
                          FinTechProfessor.com
                          https://asdocx.com
                          Check out my asdoc program, which sends outputs to MS Word.
                          For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

                          Comment


                          • #14
                            Hi, Dr. Shah:

                            Is it possible to report post-estimations like the suest command or strobel-goodman test for mediation using asdoc?

                            Comment


                            • #15
                              Also, thank you for the explanation!

                              Comment

                              Working...
                              X