Announcement

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

  • Graphing power curves given simulation results

    I recently ran some simulation analyses for a multi-level randomized control trial design in a separate programming software and generated the results. Briefly, the design has a level of clustering at the individual-level and cluster-level. I calculated the power given different combinations of number of clusters and individuals.
    Number of clusters Cluster size Intervention coefficient Estimated power
    3 5 5 0.4474474
    3 10 5 0.7377377
    3 15 5 0.8538539
    3 20 5 0.9489489
    3 25 5 0.982983
    6 5 5 0.7127127
    6 10 5 0.956957
    6 15 5 0.995996
    6 20 5 0.997998
    6 25 5 1
    What I am wondering is whether it would be possible to plot a power curve given those results, with power on the y-axis, number of clusters on the x-axis, and separate curves for the number of individuals per cluster.

    I took a look at some of the commands that are available and the power command seems like a potential candidate: https://blog.stata.com/2019/01/10/ca...-1-the-basics/. However, I am not sure that it accommodates my current situation where I am bringing in results from external to Stata.

    Is this something that is workable?

    Version: Stata 15.1
    Last edited by CEdward; 23 May 2020, 08:44.

  • #2
    Code:
    clear
    input N_clust clust_size coef power
    3   5   5   0.4474474
    3   10  5   0.7377377
    3   15  5   0.8538539
    3   20  5   0.9489489
    3   25  5   0.982983
    6   5   5   0.7127127
    6   10  5   0.956957
    6   15  5   0.995996
    6   20  5   0.997998
    6   25  5   1
    end
    
    separate power , by(clust_size) veryshortlabel
    
    
    twoway line power? power?? N_clust,   ///
        xlab(3 6) ytitle(simulated power) ///
        xtitle(number of clusters)        ///
        legend(subtitle("cluster size")   ///
               cols(3))                   ///
        lcolor("254 240 217"              ///
               "253 204 138"              ///
               "252 141  89"              ///
               "227  74  51"              ///
               "179   0   0")             ///
        scheme(s1color)
    Click image for larger version

Name:	Graph.png
Views:	1
Size:	54.8 KB
ID:	1554835
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment


    • #3
      This is perfect, Dr. Buis. I didn't realize it was as simple as using twoway line so I clearly over thought it.

      Comment


      • #4
        I was playing around with this further to add some extra details and I am not sure why I get an error. Likely it is a syntax problem, but I can't spot it:

        Code:
        twoway line Power? Power?? clusters,
        xlab(3 6 9 18 36) ///
        ytitle(Power (1 - β)) xtitle(Number of Clusters), ///
        legend(subtitle("Cluster Size") ///
        cols(1) ///
        ring(0) ///
        bplacement(seast)) ///
        lpattern(solid dash dash_dot shortdash longdash) ///
        lcolor(black black black black black) ///
        region(lcolor(white))) ///
        scheme(s1color)
        The goal here is to get a white plot region with no border around the legend. Everything else works fine when I remove region(lcolor(white))), but I am not sure why I get this error

        option region() not allowed r(198);

        Does anyone understand why this happens? Likely a syntax error?
        Last edited by CEdward; 07 Jun 2020, 16:06.

        Comment

        Working...
        X