Announcement

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

  • Add a pooling in my loop

    Hello

    I am creating a simulation for comparing different methods.
    I want to add a fixed pooling in my loop but I always got error.
    May I ask how can I fixed it?

    Thank you!


    Here's my code for the loop:

    foreach u0 of local u0list{
    foreach cluster of local clusterlist{
    forvalues i = 1/`nSims'{

    set obs `n'
    gen index = _n
    gen trt = mod(_n,2)
    gen site = mod(_n -1, `cluster') + 1
    gen u0 = rnormal(0,`u0')
    gen y = u0 + 0.4 * trt + rnormal()

    * set baseline

    fvset base 1 site


    * t test
    ttest y, by(trt)
    local tp = `r(p)'
    local tEST = r(mu_2) - r(mu_1)

    * pooling

    frame create results2 site trt se y
    forvalues s = 1/`centre' {
    regress y trt if site == `s'
    local pop = `r(p)'
    local poEST = _b[trt]
    local poSE = _se[trt]
    frame post results2 (`s') (`poEST') (`pop') (y)
    }

    cwf results2
    meta set trt se, random
    meta summarize

    frame post results (`n') (`u0') (`cluster') (`tp') (`tEST') (`poEST') (`pop')
    }

    }
    }

    cwf results
Working...
X