Announcement

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

  • Power calculation- cross-over design

    Hello,

    Does anyone have experience with power calculations in STATA for a crossover design? Trying to calculate minimal incidence rate ratio and not sure if there is an existing command to do so? Any advice is appreciated.

    Thank you!

  • #2
    Not sure about an existing command, but if not, then you can do something like the following. It's for a one-way crossover, but you can embellish the dataset (and model) with sequence assignment (AB/BA), assumptions as to carryover, and whatnot.

    .ÿ
    .ÿversionÿ16.0

    .ÿ
    .ÿclearÿ*

    .ÿ
    .ÿsetÿseedÿ`=strreverse("1527824")'

    .ÿ
    .ÿprogramÿdefineÿsimem
    ÿÿ1.ÿÿÿÿÿÿÿÿÿversionÿ16.0
    ÿÿ2.ÿÿÿÿÿÿÿÿÿsyntaxÿ,ÿn(integer)ÿ[Delta(realÿ0)]
    ÿÿ3.ÿ
    .ÿÿÿÿÿÿÿÿÿdropÿ_all
    ÿÿ4.ÿÿÿÿÿÿÿÿÿsetÿobsÿ`n'
    ÿÿ5.ÿÿÿÿÿÿÿÿÿ
    .ÿÿÿÿÿÿÿÿÿgenerateÿlongÿpidÿ=ÿ_n
    ÿÿ6.ÿÿÿÿÿÿÿÿÿgenerateÿdoubleÿpid_uÿ=ÿrnormal()
    ÿÿ7.ÿ
    .ÿÿÿÿÿÿÿÿÿexpandÿ2
    ÿÿ8.ÿÿÿÿÿÿÿÿÿbysortÿpid:ÿgenerateÿbyteÿtimÿ=ÿ_nÿ-ÿ1
    ÿÿ9.ÿ
    .ÿÿÿÿÿÿÿÿÿgenerateÿdoubleÿxbÿ=ÿpid_uÿ+ÿtimÿ*ÿ`delta'
    ÿ10.ÿÿÿÿÿÿÿÿÿgenerateÿlongÿoutÿ=ÿrpoisson(exp(xb))
    ÿ11.ÿ
    .ÿÿÿÿÿÿÿÿÿxtpoissonÿoutÿi.tim,ÿi(pid)ÿreÿnormal
    ÿ12.ÿÿÿÿÿÿÿÿÿtestÿ1.tim
    ÿ13.ÿend

    .ÿ
    .ÿprogramÿdefineÿscanem
    ÿÿ1.ÿÿÿÿÿÿÿÿÿversionÿ16.0
    ÿÿ2.ÿÿÿÿÿÿÿÿÿsyntaxÿ,ÿn(integer)ÿ[Reps(integerÿ300)ÿDelta(realÿ0)]
    ÿÿ3.ÿ
    .ÿÿÿÿÿÿÿÿÿlocalÿwhichÿ=ÿcond(`delta',ÿ"Power",ÿ"Testÿsize")
    ÿÿ4.ÿÿÿÿÿÿÿÿÿquietlyÿsimulateÿpÿ=ÿr(p),ÿreps(`reps'):ÿsimemÿ,ÿn(`n')ÿd(`delta')
    ÿÿ5.ÿÿÿÿÿÿÿÿÿgenerateÿbyteÿposÿ=ÿpÿ<ÿ0.05ÿifÿ!mi(p)
    ÿÿ6.ÿÿÿÿÿÿÿÿÿsummarizeÿpos,ÿmeanonly
    ÿÿ7.ÿÿÿÿÿÿÿÿÿdisplayÿinÿsmclÿasÿtextÿ"Nÿ=ÿ"ÿ`n',ÿ"`which'ÿ=ÿ"ÿ%04.2fÿr(mean)
    ÿÿ8.ÿend

    .ÿ
    .ÿ
    .ÿ//ÿIRRÿofÿ1.25
    .ÿforvaluesÿnÿ=ÿ150(50)250ÿ{
    ÿÿ2.ÿÿÿÿÿÿÿÿÿscanemÿ,ÿn(`n')ÿd(`=ln(1.25)')
    ÿÿ3.ÿ}
    Nÿ=ÿ150ÿPowerÿ=ÿ0.74
    Nÿ=ÿ200ÿPowerÿ=ÿ0.88
    Nÿ=ÿ250ÿPowerÿ=ÿ0.92

    .ÿ
    .ÿ//ÿTestÿsize
    .ÿscanemÿ,ÿn(200)
    Nÿ=ÿ200ÿTestÿsizeÿ=ÿ0.04

    .ÿ
    .ÿexit

    endÿofÿdo-file


    .


    After honing in, you can up the repetitions to get more precise estimates with the chosen delta and sample size.

    Comment

    Working...
    X