Announcement

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

  • Table of stored values after estat sbsingle or sbcusum?

    I am trying to make a table of p values and chi-squared test statistics(or r(cusum)s) after estat sbsingle and estat sbcusum. Can anyone help?

  • #2
    local ivars1 x1 z1 t1 s1
    local ivars2 x2 z2 t2 s2
    .
    .
    .

    reg y1 `ivars1'
    estat sbsingle
    estat sbcusum
    graph save sb2
    reg y2 `ivars2'
    estat sbsingle
    estat sbcusum
    graph save sb2
    .
    .
    .

    graph combine sb1.gph sb2.gph

    ı do it one by one ı want to build loop for the next tries.

    Comment


    • #3
      Something like this:

      Code:
      local to_combine
      forvalues i = 1/21 {
          local ivars x`i' z`i' t`i' s`i'
          // PERHAPS OTHER COMMANDS HERE
          reg y`i' `ivars'
          estat sbsingle
          estat sbcusum
          graph save sb`i'
          local to_combine `to_combine' sb`i'
      }
      graph combine `to_combine'
      Note: If you really have 21 analyses, I think that the combined graph with 21 panels will be unreadable as each panel will be very small. So you might want to rethink the combined graph.

      Comment


      • #4
        ıt works Dear Schechter. But ı cant get the p values and test statistics of estat sbsingle and estat sbcusum. It gives me the p values and test statistics of the regressions.

        Comment


        • #5
          I'm not familiar with -estat sbsingle- and -estat sbccusum-. But I see that they are built-in Stata commands. There is nothing in the code that would cause Stata to silence their output, so I really don't see how to help you with this. Why don't you show the exact code you are running along with the exact output you are getting from Stata? (If you are really doing 21 regressions, don't show the output for all 21; just show the first few.)

          Comment


          • #6

            local ivars1 x1 z1 t1 s1
            local ivars2 x2 z2 t2 s2
            local ivars3 x3 z3 t3 s3
            local depvars y1 y2 y3




            forvalues i=1/3 {
            local ivars ltexits`i' lcredits`i' rrates`i' llabors`i'
            qui reg ltentrys`i' `ivars'
            qui estat sbsingle
            qui estat sbcusum
            graph save sb`i'
            estimates store s`i'
            esttab s`i' using example`i', scalars(Zt p)

            local to combine `to_combine' sb`i'
            }
            graph combine `to_combine'

            blue colored part is where ı am stuck not only for the loop but also one by one. ı have 21 example sheet (contains outputs of reg ltentrys`i' `ivars' not estat sbsingle or cusum). ı need one table of estat sbsingle and cusum outputs.

            Comment


            • #7
              Oh, so you're problem is that -esttab- is not picking these things up. That doesn't surprise me, as -esttab- only picks up things left in e() unless you specify other things in the -stats()- option. The -stats()- option is actually an option of -estout-, but -esttab- is a wrapper for -estout- and passes it through. I'll deal here with -estat sbsingle- and then you can modify the code for -estat sbcusum- analogously. -estat sbsingle- leaves behind a chi square test statistics in r(chi2), a p-value in r(p), and the degrees of freedom in r(df). So you need to do something like this:

              Code:
              forvalues i=1/3 {
                  local ivars ltexits`i' lcredits`i' rrates`i' llabors`i'
                  qui reg ltentrys`i' `ivars'
                  qui estat sbsingle
                  scalar sbsingle_p = r(p)
                  scalar sbsingle_chi2 = r(chi2)
                  scalar sbsingle_df = r(df)
                  qui estat sbcusum
                  graph save sb`i'
                  estimates store s`i'
                  esttab s`i' using example`i', scalars(Zt p) ///
                      stats(sbsingle_p sbsingle_chi2 sbsingle_df)
                  local to combine `to_combine' sb`i'
              }
              graph combine `to_combine'
              You may want to modify the -stats()- option to specify formatting, et See -help estout- for details of that. You should add similar code after -qui estat sbcusum- to pick up the statistics it leaves behind in r() as scalars, and then add them to the -stats()- option.

              Comment

              Working...
              X