Announcement

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

  • #16
    Is there a way to do that for different numbers of clusters? I think for n = 6 clusters the above solution works fine. But I want to equally distribute the number of clusters by the number of steps for different numbers of clusters (e.g. n = 3 clusters is 1 cluster per step, n = 12 clusters is 4 clusters per step).

    Comment


    • #17
      Ultimately, I want to create a dataset where intrv = 1 whenever a cluster switches to the intervention at a time step and 0 otherwise. I want to have an even number of clusters switching to the intervention at each step. So in the example below, there are n = 3 clusters and each cluster (and the individuals in that cluster) switch at time 1, 2, and 3, respectively. I want to do the same thing for n = 3, 6, 9, 18, and 36 clusters. Is there a loop of some sort? Note: The u_3, u_2 variables below can be ignored.

      clear
      input float(cluster u_3 individual u_2 time intrv)
      1 .1143134 1 -.7576806 0 0
      1 .1143134 1 -.7576806 1 1
      1 .1143134 1 -.7576806 2 1
      1 .1143134 1 -.7576806 3 1
      1 .1143134 1 -.7576806 4 1
      1 .1143134 1 -.7576806 5 1
      1 .1143134 2 .636223 0 0
      1 .1143134 2 .636223 1 1
      1 .1143134 2 .636223 2 1
      1 .1143134 2 .636223 3 1
      1 .1143134 2 .636223 4 1
      1 .1143134 2 .636223 5 1
      2 .0930611 1 -.50105065 0 0
      2 .0930611 1 -.50105065 1 0
      2 .0930611 1 -.50105065 2 1
      2 .0930611 1 -.50105065 3 1
      2 .0930611 1 -.50105065 4 1
      2 .0930611 1 -.50105065 5 1
      2 .0930611 2 -.3535455 0 0
      2 .0930611 2 -.3535455 1 0
      2 .0930611 2 -.3535455 2 1
      2 .0930611 2 -.3535455 3 1
      2 .0930611 2 -.3535455 4 1
      2 .0930611 2 -.3535455 5 1
      3 .4748023 1 .29760918 0 0
      3 .4748023 1 .29760918 1 0
      3 .4748023 1 .29760918 2 0
      3 .4748023 1 .29760918 3 1
      3 .4748023 1 .29760918 4 1
      3 .4748023 1 .29760918 5 1
      3 .4748023 2 .8398623 0 0
      3 .4748023 2 .8398623 1 0
      3 .4748023 2 .8398623 2 0
      3 .4748023 2 .8398623 3 1
      3 .4748023 2 .8398623 4 1
      3 .4748023 2 .8398623 5 1
      end
      [/CODE]

      Would it even be necessary to go through the trouble of creating a variable indicating the randomization sequence (or group) for a cluster?
      Last edited by CEdward; 22 Nov 2019, 20:56.

      Comment


      • #18
        Here is the solution for anybody that is interested in using this design:
        Code:
        set obs `num_clus'  //*Number of clusters*//
        qui gen cluster = _n
        qui gen group = 1+mod(_n-1,3) //*Where 3 is the number of steps*//
        expand `clussize'
        bysort cluster: gen individual = _n
        expand 6 //*Number of periods//
        bysort cluster individual: gen time = _n-1 //*Set up time variable*//
        gen intrv = (time>=group) //*Intervention variable*//

        Comment

        Working...
        X