Announcement

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

  • Can anyone help me loop these lengthy codes?

    Code:
    matrix table1=J(6,6,.)
    
    ttest preaddition == postaddition
    matrix table1[1,1] = r(mu_1)
    matrix table1[1,2] = r(sd_1)/sqrt(r(N_1))
    matrix table1[1,3] = r(mu_2)
    matrix table1[1,4] = r(sd_2)/sqrt(r(N_2))
    matrix table1[1,5] = r(t)
    
    ttest predeletion == postdeletion
    matrix table1[2,1] = r(mu_1)
    matrix table1[2,2] = r(sd_1)/sqrt(r(N_1))
    matrix table1[2,3] = r(mu_2)
    matrix table1[2,4] = r(sd_2)/sqrt(r(N_2))
    matrix table1[2,5] = r(t)
    
    ttest pretotal == posttotal
    matrix table1[3,1] = r(mu_1)
    matrix table1[3,2] = r(sd_1)/sqrt(r(N_1))
    matrix table1[3,3] = r(mu_2)
    matrix table1[3,4] = r(sd_2)/sqrt(r(N_2))
    matrix table1[3,5] = r(t)
    
    
    matrix list table1

  • #2
    Perhaps this (untested) example will point the way to a solution.
    Code:
    matrix table1=J(6,6,.)
    
    local i = 0
    foreach c in addition deletion total {
        local i = `i'+1
        ttest pre`c' == post`c'
        matrix table1[`i',1] = r(mu_1)
        matrix table1[`i',2] = r(sd_1)/sqrt(r(N_1))
        matrix table1[`i',3] = r(mu_2)
        matrix table1[`i',4] = r(sd_2)/sqrt(r(N_2))
        matrix table1[`i',5] = r(t)
    }
    
    matrix list table1

    Comment


    • #3
      that's correct! I really appreciate you!

      Comment

      Working...
      X