Announcement

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

  • Stratified t-test in Stata

    1. Please can any one explain the procedure for conducting stratified t-test in Stata (assuming intervention arm and strata to be the two factors in a cluster-level analysis of a stratified cluster randomised trial)?

  • #2
    You might want to post your question in the General forum. This Sandbox forum is for testing the post's display.

    More to your question: couldn't you use mixed with its degrees-of-freedom corrections to get the stratified t statistic and its p-value in the context of a cluster-randomized trial? Something like that below?

    .ÿversionÿ14.2

    .ÿ
    .ÿclearÿ*

    .ÿsetÿmoreÿoff

    .ÿsetÿseedÿ1374242

    .ÿ
    .ÿ//ÿClusters
    .ÿquietlyÿsetÿobsÿ50

    .ÿgenerateÿbyteÿcidÿ=ÿ_n

    .ÿlabelÿvariableÿcidÿ"ClusterÿID"

    .ÿgenerateÿdoubleÿcid_uÿ=ÿrnormal()

    .ÿ
    .ÿ//ÿCluster-randomizedÿinterventionÿarm
    .ÿgenerateÿbyteÿtrtÿ=ÿmod(_n,ÿ2)

    .ÿlabelÿvariableÿtrtÿTreatment

    .ÿlabelÿdefineÿTrtÿ0ÿControlÿ1ÿExperimental

    .ÿlabelÿvaluesÿtrtÿTrt

    .ÿ
    .ÿ//ÿIndividuals
    .ÿquietlyÿexpandÿ50

    .ÿbysortÿcid:ÿgenerateÿdoubleÿpid_uÿ=ÿrnormal()

    .ÿgenerateÿintÿpidÿ=ÿ_n

    .ÿlabelÿvariableÿpidÿ"ParticipantÿID"

    .ÿ
    .ÿ//ÿStrata
    .ÿgenerateÿbyteÿsidÿ=ÿmod(_n+4,ÿ5)

    .ÿlabelÿvariableÿsidÿ"Stratum"

    .ÿlabelÿdefineÿStrataÿ0ÿ"Veryÿlow"ÿ1ÿLowÿ2ÿMediumÿ3ÿHighÿ4ÿ"Veryÿhigh"

    .ÿlabelÿvaluesÿsidÿStrata

    .ÿ
    .ÿgenerateÿdoubleÿoutÿ=ÿcid_uÿ+ÿpid_uÿ+ÿsidÿ/ÿ25ÿ+ÿtrtÿ/ÿ2.5ÿ+ÿ0ÿ*ÿsidÿ*ÿtrt

    .ÿlabelÿvariableÿoutÿOutcome

    .ÿformatÿoutÿ%3.2f

    .ÿ
    .ÿsortÿcidÿpidÿsid

    .ÿforeachÿvarÿofÿvarlistÿ*tÿ*dÿ{
    ÿÿ2.ÿÿÿÿÿÿÿÿÿlocalÿvariable_labelÿ:ÿvariableÿlabelÿ`var'
    ÿÿ3.ÿÿÿÿÿÿÿÿÿcharÿdefineÿ`var'[varname]ÿ`variable_label'
    ÿÿ4.ÿ
    .ÿÿÿÿÿÿÿÿÿlocalÿlabel_lengthÿ=ÿstrlen("`variable_label'")
    ÿÿ5.ÿÿÿÿÿÿÿÿÿifÿ"`var'"ÿ==ÿ"out"ÿformatÿ`var'ÿ%`label_length'.2f
    ÿÿ6.ÿÿÿÿÿÿÿÿÿelseÿifÿ!inlist("`var'",ÿ"trt",ÿ"sid")ÿformatÿ`var'ÿ%`label_length'.0f
    ÿÿ7.ÿÿÿÿÿÿÿÿÿelseÿ{
    ÿÿ8.ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ//ÿnoÿop
    .ÿÿÿÿÿÿÿÿÿ}
    ÿÿ9.ÿ}

    .ÿlistÿcidÿtrtÿpidÿsidÿoutÿifÿinrange(_n,ÿ1,ÿ5)ÿ|ÿinrange(_n,ÿ`=_N-4',ÿ`=_N'),ÿ///
    >ÿÿÿÿÿÿÿÿÿnoobsÿsepby(trt)ÿsubvarnameÿnocompress

    ÿÿ+------------------------------------------------------------------+
    ÿÿ|ÿClusterÿIDÿÿÿÿÿÿTreatmentÿÿÿParticipantÿIDÿÿÿÿÿStratumÿÿÿOutcomeÿ|
    ÿÿ|------------------------------------------------------------------|
    ÿÿ|ÿÿÿÿÿÿÿÿÿÿ1ÿÿÿExperimentalÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ1ÿÿÿÿVeryÿlowÿÿÿÿÿ-2.28ÿ|
    ÿÿ|ÿÿÿÿÿÿÿÿÿÿ1ÿÿÿExperimentalÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ2ÿÿÿÿÿÿÿÿÿLowÿÿÿÿÿ-0.12ÿ|
    ÿÿ|ÿÿÿÿÿÿÿÿÿÿ1ÿÿÿExperimentalÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ3ÿÿÿÿÿÿMediumÿÿÿÿÿÿ1.04ÿ|
    ÿÿ|ÿÿÿÿÿÿÿÿÿÿ1ÿÿÿExperimentalÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ4ÿÿÿÿÿÿÿÿHighÿÿÿÿÿ-1.64ÿ|
    ÿÿ|ÿÿÿÿÿÿÿÿÿÿ1ÿÿÿExperimentalÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ5ÿÿÿVeryÿhighÿÿÿÿÿ-0.81ÿ|
    ÿÿ|------------------------------------------------------------------|
    ÿÿ|ÿÿÿÿÿÿÿÿÿ50ÿÿÿÿÿÿÿÿControlÿÿÿÿÿÿÿÿÿÿÿÿÿ2496ÿÿÿÿVeryÿlowÿÿÿÿÿÿ2.47ÿ|
    ÿÿ|ÿÿÿÿÿÿÿÿÿ50ÿÿÿÿÿÿÿÿControlÿÿÿÿÿÿÿÿÿÿÿÿÿ2497ÿÿÿÿÿÿÿÿÿLowÿÿÿÿÿÿ0.41ÿ|
    ÿÿ|ÿÿÿÿÿÿÿÿÿ50ÿÿÿÿÿÿÿÿControlÿÿÿÿÿÿÿÿÿÿÿÿÿ2498ÿÿÿÿÿÿMediumÿÿÿÿÿÿ0.22ÿ|
    ÿÿ|ÿÿÿÿÿÿÿÿÿ50ÿÿÿÿÿÿÿÿControlÿÿÿÿÿÿÿÿÿÿÿÿÿ2499ÿÿÿÿÿÿÿÿHighÿÿÿÿÿÿ0.24ÿ|
    ÿÿ|ÿÿÿÿÿÿÿÿÿ50ÿÿÿÿÿÿÿÿControlÿÿÿÿÿÿÿÿÿÿÿÿÿ2500ÿÿÿVeryÿhighÿÿÿÿÿ-1.06ÿ|
    ÿÿ+------------------------------------------------------------------+

    .ÿ
    .ÿ*
    .ÿ*ÿBeginÿhere
    .ÿ*
    .ÿmixedÿoutÿi.trtÿi.sidÿ||ÿcid:ÿ,ÿremlÿdfmethod(kroger)ÿnolrtestÿnolog

    Mixed-effectsÿREMLÿregressionÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿobsÿÿÿÿÿ=ÿÿÿÿÿÿ2,500
    Groupÿvariable:ÿcidÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿgroupsÿÿ=ÿÿÿÿÿÿÿÿÿ50

    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿObsÿperÿgroup:
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿminÿ=ÿÿÿÿÿÿÿÿÿ50
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿavgÿ=ÿÿÿÿÿÿÿ50.0
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿmaxÿ=ÿÿÿÿÿÿÿÿÿ50
    DFÿmethod:ÿKenward-RogerÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿDF:ÿÿÿÿÿÿÿÿÿÿÿminÿ=ÿÿÿÿÿÿ48.00
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿavgÿ=ÿÿÿ1,647.45
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿmaxÿ=ÿÿÿ2,446.00

    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿF(5,ÿÿÿ481.04)ÿÿÿÿ=ÿÿÿÿÿÿÿ5.05
    Logÿrestricted-likelihoodÿ=ÿ-3651.2343ÿÿÿÿÿÿÿÿÿÿProbÿ>ÿFÿÿÿÿÿÿÿÿÿÿ=ÿÿÿÿÿ0.0002

    -------------------------------------------------------------------------------
    ÿÿÿÿÿÿÿÿÿÿoutÿ|ÿÿÿÿÿÿCoef.ÿÿÿStd.ÿErr.ÿÿÿÿÿÿtÿÿÿÿP>|t|ÿÿÿÿÿ[95%ÿConf.ÿInterval]
    --------------+----------------------------------------------------------------
    ÿÿÿÿÿÿÿÿÿÿtrtÿ|
    Experimentalÿÿ|ÿÿÿ.5816661ÿÿÿ.2588292ÿÿÿÿÿ2.25ÿÿÿ0.029ÿÿÿÿÿ.0612551ÿÿÿÿ1.102077
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿ|
    ÿÿÿÿÿÿÿÿÿÿsidÿ|
    ÿÿÿÿÿÿÿÿÿLowÿÿ|ÿÿÿ.1032732ÿÿÿ.0633495ÿÿÿÿÿ1.63ÿÿÿ0.103ÿÿÿÿÿ-.020951ÿÿÿÿ.2274974
    ÿÿÿÿÿÿMediumÿÿ|ÿÿÿ.1541544ÿÿÿ.0633495ÿÿÿÿÿ2.43ÿÿÿ0.015ÿÿÿÿÿ.0299302ÿÿÿÿ.2783786
    ÿÿÿÿÿÿÿÿHighÿÿ|ÿÿÿ.2309975ÿÿÿ.0633495ÿÿÿÿÿ3.65ÿÿÿ0.000ÿÿÿÿÿ.1067733ÿÿÿÿ.3552217
    ÿÿÿVeryÿhighÿÿ|ÿÿÿÿ.247529ÿÿÿ.0633495ÿÿÿÿÿ3.91ÿÿÿ0.000ÿÿÿÿÿ.1233049ÿÿÿÿ.3717532
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿ|
    ÿÿÿÿÿÿÿÿ_consÿ|ÿÿÿ-.359458ÿÿÿÿ.187354ÿÿÿÿ-1.92ÿÿÿ0.060ÿÿÿÿ-.7352911ÿÿÿÿ.0163751
    -------------------------------------------------------------------------------

    ------------------------------------------------------------------------------
    ÿÿRandom-effectsÿParametersÿÿ|ÿÿÿEstimateÿÿÿStd.ÿErr.ÿÿÿÿÿ[95%ÿConf.ÿInterval]
    -----------------------------+------------------------------------------------
    cid:ÿIdentityÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ|
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿvar(_cons)ÿ|ÿÿÿÿ.817341ÿÿÿ.1709359ÿÿÿÿÿÿ.5424827ÿÿÿÿ1.231461
    -----------------------------+------------------------------------------------
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿvar(Residual)ÿ|ÿÿÿ1.003289ÿÿÿ.0286888ÿÿÿÿÿÿ.9486069ÿÿÿÿ1.061124
    ------------------------------------------------------------------------------

    .ÿ
    .ÿexit

    endÿofÿdo-file


    .

    Comment


    • #3
      Thanks very much. I thought i was posting the question in the general forum. I will do that. Notwithstanding, `The text am consulting ("cluster randomized trials" by Hayes and Moulton 2009) recommended cluster-level analysis for trials with small number of clusters per arm (less than 15). With proportion as the primary outcome measure, this involves (1). a one-stage process of estimating the mean of cluster summaries/proportions in each arm and using the mean difference for significance testing with stratified t-test in Stata (2). Adjustment for covariates employs individual-level analysis with random effect logistic regression (for proportion). There is ". xi: regress outcome i. arm* i. stratum" command in the Stata output of an example in the text. Please, can such analysis be done with the point-and-click GUI In Stata?

      Comment

      Working...
      X