Announcement

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

  • Extract data from 1000 regression tables

    Hi,

    I am using this command below for 1000 variables as an outcome.

    foreach outcome of varlist B-ARP{
    regress `outcome' bmi Age i.sex i.smoking i.lpa2c i.cholestrol
    }

    I would like to know how I can extract data for those with significant results from 1000 tables.


  • #2
    just to clarify my question I want to extract significant p-values and confidence intervals from thousand tables. and save them in excel file.

    Comment


    • #3
      your question is not very clear but you should have a look at the following:
      Code:
      h statsby
      h runby
      h table
      h collect
      note that -runby- is community contributed - use -search- to locate and download; note also that -table- and -collect- are only useful if you are using Stata 17; for -statsby- and, I think, -runby- you end up with a Stata data set that you then need to export to excel:
      Code:
      h export excel
      for table/collect you can export using -collect export-; see
      Code:
      h collect export

      Comment


      • #4
        Thanks Rich. I will try these codes.

        And I apologize for being unclear in my question. But what I am trying to clarify is that I have run the above command and I got 1000 tables, so I am trying to find where the association between the exposure and outcomes was significant without going to each table one by one, and then arrange these significant associations in one table in Excel format.

        Comment


        • #5
          Unfortunately these cods didn't solve my problem.

          Comment


          • #6
            It is unclear what you mean by extracting significant results. Can you clarify?

            Comment


            • #7
              Hi,

              I have applied this code

              PHP Code:
              local counter 0
              local counter_pos 
              0
              local counter_neg 
              0

              foreach outcome of varlist APW-AQE {
                  
              regress `outcome' bmi Age i.sex i.smoking i.lpa2c i.cholestrol
                  matrix M = r(table)
                  if M[4, 1] < 0.05 {
                      local ++counter
                      if _b[bmi] < 0 {
                          local ++counter_neg
                      }
                      else {
                          local ++counter_pos
                      }
                  }
              }


              display as text "Number of positive significant: " as result 
              `counter_pos'
              display as text "Number of negative significant: " as result `counter_neg'
              display as text "Total of significant results: " as result `counter' 
              It was based on the link attached. The code worked with me but the problem This what I got

              PHP Code:
              display as text "Number of positive significant: " as result `counter_pos'
              Number of positive significant: 1

              . display as text "Number of negative significant: " as result 
              `counter_neg'
              Number of negative significant: 3

              . display as text "Total of significant results: " as result `counter'
              Total of significant results
              It didn't specify which variables only gave me that there is 4 significant variables.
              so I would like to know how I can get the names of these variables.
              Hello, I am using the following command "bysort var: reg y x". In doing so, I get many results. However, I am only interested to know whether the

              Comment


              • #8
                in what way did "these cods didn't [not] solve my problem."? yes, you might need a second step to cull out what you want from the total - is that the problem? if not, what is your problem?

                Comment


                • #9
                  Yes, it seems to me that there are four significant results, but I would like to get the names of the four variables.

                  Comment


                  • #10
                    See https://www.statalist.org/forums/for...occurred/page2 at #17.

                    Added: Why you want to do this baffles me. Surely with 1,000 regressions, the occurrence of 4 results "significant" at the .05 level tells you nothing at all about those relationships. In fact, in purely random data with no associations at all, you would expect .05*1000 = 50 "significant" results. The remarkable thing is that you somehow got only 4--and there is really no reason to think that those are meaningful.
                    Last edited by Clyde Schechter; 11 Feb 2023, 12:11.

                    Comment


                    • #11
                      Thanks Mr. Clyde.

                      By mistake, I mentioned 4 because when I have tried the command, I just include 10 variables out of a total of 1000 to see if the command will give me what I want.

                      I really appreciate your help. I will check the post that you have mentioned.

                      Comment


                      • #12
                        Why don't you use -test- to probe each coefficient in each model?

                        Comment

                        Working...
                        X