Announcement

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

  • #16
    Originally posted by Clyde Schechter View Post
    Code:
    levelsof var, local(var_levels)
    local counter = 0
    local counter_pos = 0
    local counter_neg = 0
    foreach v of local var_levels {
    regress y x if var == `v'
    matrix M = r(table)
    if M[4, 1] < 0.05 {
    local ++counter
    if _b[x] < 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'"
    This command was working with me very well. but I would like to know if it possible to get the name of significant variables in addition to numbers. And could I present all significant variables in one table ? and then save it in an Excel file?

    Comment


    • #17
      Code:
      levelsof var, local(var_levels)
      local counter = 0
      local counter_pos = 0
      local counter_neg = 0
      frame create significant int var float(coeff ll ul pvalue)
      foreach v of local var_levels {
          regress y x if var == `v'
          matrix M = r(table)
          if M[4, 1] < 0.05 {
              local ++counter
              if _b[x] < 0 {
                  local ++counter_neg
              }
              else {
                  local ++counter_pos
              }
              frame post significant (`v') (M["b","x"]) (M["ll", "x"]) ///
                  (M["ul", "x"]) (M["pvalue", "x"])
          }
      }
      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'
      
      frame significant {
          list, noobs clean
      }
      The table you want is now in -frame significant-. To export it to Excel, use the -export excel- command instead of -list, noobs clean-.

      Note: As the code uses frames, it requires version 16 or later.

      Comment

      Working...
      X