Announcement

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

  • Comparing differences in proportions across different time points and different groups simultaneously

    Is it possible to compare changes in proportions of a variable across different time points eg baseline and one year later and compare if the changes were significant across four groups. What statistical test would you use to do this at once?

  • #2
    Hello Brenda. Do you mean that the outcome variable for each subject at each time point is a proportion (i.e., a value in the range 0-1)? Or do you mean the proportion of events for each group x time point combination, where the outcome variable is dichotomous (1=event, 0=no event)? Thanks for clarifying.
    --
    Bruce Weaver
    Email: [email protected]
    Version: Stata/MP 19.5 (Windows)

    Comment


    • #3
      Originally posted by Brenda Oulo View Post
      Is it possible to compare changes in proportions of a variable across different time points eg baseline and one year later and compare if the changes were significant across four groups. What statistical test would you use to do this at once?
      What would I do? This:

      .ÿversionÿ15.1

      .ÿ
      .ÿclearÿ*

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

      .ÿ
      .ÿquietlyÿsetÿobsÿ400

      .ÿ
      .ÿgenerateÿbyteÿgrpÿ=ÿmod(_n,ÿ4)ÿ+ÿ1

      .ÿgenerateÿintÿpidÿ=ÿ_n

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

      .ÿ
      .ÿquietlyÿexpandÿ2

      .ÿbysortÿpid:ÿgenerateÿbyteÿtimÿ=ÿ_nÿ-ÿ1

      .ÿlabelÿdefineÿTimesÿ0ÿBaselineÿ1ÿ"OneÿYearÿLater"

      .ÿlabelÿvaluesÿtimÿTimes

      .ÿ
      .ÿgenerateÿdoubleÿxbÿ=ÿpid_uÿ+ÿ(timÿ-ÿ0.5)ÿ/ÿ5ÿ+ÿ0ÿ*ÿgrp

      .ÿgenerateÿbyteÿoutÿ=ÿrbinomial(1,ÿnormal(xb))

      .ÿ
      .ÿ*
      .ÿ*ÿBeginÿhere
      .ÿ*
      .ÿmelogitÿoutÿi.tim##i.grpÿ||ÿpid:ÿ,ÿnolrtestÿnolog

      Mixed-effectsÿlogisticÿregressionÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿobsÿÿÿÿÿ=ÿÿÿÿÿÿÿÿ800
      Groupÿvariable:ÿÿÿÿÿÿÿÿÿÿÿÿÿpidÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿgroupsÿÿ=ÿÿÿÿÿÿÿÿ400

      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿObsÿperÿgroup:
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿminÿ=ÿÿÿÿÿÿÿÿÿÿ2
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿavgÿ=ÿÿÿÿÿÿÿÿ2.0
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿmaxÿ=ÿÿÿÿÿÿÿÿÿÿ2

      Integrationÿmethod:ÿmvaghermiteÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿIntegrationÿpts.ÿÿ=ÿÿÿÿÿÿÿÿÿÿ7

      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿWaldÿchi2(7)ÿÿÿÿÿÿ=ÿÿÿÿÿÿÿ7.55
      Logÿlikelihoodÿ=ÿ-535.53328ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿProbÿ>ÿchi2ÿÿÿÿÿÿÿ=ÿÿÿÿÿ0.3736
      -----------------------------------------------------------------------------------
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿoutÿ|ÿÿÿÿÿÿCoef.ÿÿÿStd.ÿErr.ÿÿÿÿÿÿzÿÿÿÿP>|z|ÿÿÿÿÿ[95%ÿConf.ÿInterval]
      ------------------+----------------------------------------------------------------
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿtimÿ|
      ÿÿOneÿYearÿLaterÿÿ|ÿÿÿ.3261806ÿÿÿÿ.330781ÿÿÿÿÿ0.99ÿÿÿ0.324ÿÿÿÿ-.3221381ÿÿÿÿ.9744994
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ|
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿgrpÿ|
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ2ÿÿ|ÿÿ-.0045098ÿÿÿ.3897205ÿÿÿÿ-0.01ÿÿÿ0.991ÿÿÿÿÿ-.768348ÿÿÿÿ.7593284
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ3ÿÿ|ÿÿÿ.2741965ÿÿÿ.3894445ÿÿÿÿÿ0.70ÿÿÿ0.481ÿÿÿÿ-.4891008ÿÿÿÿ1.037494
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ4ÿÿ|ÿÿ-.0562407ÿÿÿÿ.388454ÿÿÿÿ-0.14ÿÿÿ0.885ÿÿÿÿ-.8175965ÿÿÿÿ.7051152
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ|
      ÿÿÿÿÿÿÿÿÿÿtim#grpÿ|
      OneÿYearÿLater#2ÿÿ|ÿÿÿÿ.350766ÿÿÿ.4733769ÿÿÿÿÿ0.74ÿÿÿ0.459ÿÿÿÿ-.5770356ÿÿÿÿ1.278568
      OneÿYearÿLater#3ÿÿ|ÿÿ-.2149571ÿÿÿ.4695375ÿÿÿÿ-0.46ÿÿÿ0.647ÿÿÿÿ-1.135234ÿÿÿÿ.7053195
      OneÿYearÿLater#4ÿÿ|ÿÿÿ.1690006ÿÿÿ.4690604ÿÿÿÿÿ0.36ÿÿÿ0.719ÿÿÿÿ-.7503409ÿÿÿÿ1.088342
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ|
      ÿÿÿÿÿÿÿÿÿÿÿÿ_consÿ|ÿÿ-.1083377ÿÿÿ.2740771ÿÿÿÿ-0.40ÿÿÿ0.693ÿÿÿÿÿ-.645519ÿÿÿÿ.4288436
      ------------------+----------------------------------------------------------------
      pidÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ|
      ÿÿÿÿÿÿÿÿvar(_cons)|ÿÿÿ1.997928ÿÿÿ.5939636ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ1.115646ÿÿÿÿ3.577943
      -----------------------------------------------------------------------------------

      .ÿ
      .ÿ//ÿIfÿIÿwantedÿtoÿtestÿriskÿdifference,ÿmarginalizedÿoverÿgroups
      .ÿmarginsÿr.tim

      Contrastsÿofÿpredictiveÿmargins
      ModelÿVCEÿÿÿÿ:ÿOIM

      Expressionÿÿÿ:ÿMarginalÿpredictedÿmean,ÿpredict()

      ------------------------------------------------
      ÿÿÿÿÿÿÿÿÿÿÿÿÿ|ÿÿÿÿÿÿÿÿÿdfÿÿÿÿÿÿÿÿchi2ÿÿÿÿÿP>chi2
      -------------+----------------------------------
      ÿÿÿÿÿÿÿÿÿtimÿ|ÿÿÿÿÿÿÿÿÿÿ1ÿÿÿÿÿÿÿÿ5.85ÿÿÿÿÿ0.0155
      ------------------------------------------------

      -------------------------------------------------------------------------------
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ|ÿÿÿÿÿÿÿÿÿÿÿÿDelta-method
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ|ÿÿÿContrastÿÿÿStd.ÿErr.ÿÿÿÿÿ[95%ÿConf.ÿInterval]
      ------------------------------+------------------------------------------------
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿtimÿ|
      (OneÿYearÿLaterÿvsÿBaseline)ÿÿ|ÿÿÿ.0727963ÿÿÿ.0300885ÿÿÿÿÿÿÿ.013824ÿÿÿÿ.1317687
      -------------------------------------------------------------------------------

      .ÿ//ÿor
      .ÿmarginsÿ,ÿdydx(tim)

      AverageÿmarginalÿeffectsÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿobsÿÿÿÿÿ=ÿÿÿÿÿÿÿÿ800
      ModelÿVCEÿÿÿÿ:ÿOIM

      Expressionÿÿÿ:ÿMarginalÿpredictedÿmean,ÿpredict()
      dy/dxÿw.r.t.ÿ:ÿ1.tim

      ---------------------------------------------------------------------------------
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ|ÿÿÿÿÿÿÿÿÿÿÿÿDelta-method
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ|ÿÿÿÿÿÿdy/dxÿÿÿStd.ÿErr.ÿÿÿÿÿÿzÿÿÿÿP>|z|ÿÿÿÿÿ[95%ÿConf.ÿInterval]
      ----------------+----------------------------------------------------------------
      ÿÿÿÿÿÿÿÿÿÿÿÿtimÿ|
      OneÿYearÿLaterÿÿ|ÿÿÿ.0727963ÿÿÿ.0300885ÿÿÿÿÿ2.42ÿÿÿ0.016ÿÿÿÿÿÿ.013824ÿÿÿÿ.1317686
      ---------------------------------------------------------------------------------
      Note:ÿdy/dxÿforÿfactorÿlevelsÿisÿtheÿdiscreteÿchangeÿfromÿtheÿbaseÿlevel.

      .ÿ
      .ÿ//ÿIfÿinsteadÿIÿwantedÿaÿsimultaneousÿtestÿofÿindividual-groupÿriskÿdifferences
      .ÿmarginsÿtim,ÿover(grp)ÿcontrast(waldÿwithinjointÿnoatlevels)

      Contrastsÿofÿpredictiveÿmargins
      ModelÿVCEÿÿÿÿ:ÿOIM

      Expressionÿÿÿ:ÿMarginalÿpredictedÿmean,ÿpredict()
      overÿÿÿÿÿÿÿÿÿ:ÿgrp

      ------------------------------------------------
      ÿÿÿÿÿÿÿÿÿÿÿÿÿ|ÿÿÿÿÿÿÿÿÿdfÿÿÿÿÿÿÿÿchi2ÿÿÿÿÿP>chi2
      -------------+----------------------------------
      ÿÿÿÿÿtim@grpÿ|ÿÿÿÿÿÿÿÿÿÿ4ÿÿÿÿÿÿÿÿ7.41ÿÿÿÿÿ0.1159
      ------------------------------------------------

      .ÿ//ÿor
      .ÿquietlyÿmarginsÿtim#grp,ÿpost

      .ÿquietlyÿtestÿ0.tim#1.grpÿ=ÿ1.tim#1.grp,ÿnotest

      .ÿquietlyÿtestÿ0.tim#2.grpÿ=ÿ1.tim#2.grp,ÿnotestÿaccumulate

      .ÿquietlyÿtestÿ0.tim#3.grpÿ=ÿ1.tim#3.grp,ÿnotestÿaccumulate

      .ÿtestÿ0.tim#4.grpÿ=ÿ1.tim#4.grp,ÿaccumulate

      ÿ(ÿ1)ÿÿ0bn.tim#1bn.grpÿ-ÿ1.tim#1bn.grpÿ=ÿ0
      ÿ(ÿ2)ÿÿ0bn.tim#2.grpÿ-ÿ1.tim#2.grpÿ=ÿ0
      ÿ(ÿ3)ÿÿ0bn.tim#3.grpÿ-ÿ1.tim#3.grpÿ=ÿ0
      ÿ(ÿ4)ÿÿ0bn.tim#4.grpÿ-ÿ1.tim#4.grpÿ=ÿ0

      ÿÿÿÿÿÿÿÿÿÿÿchi2(ÿÿ4)ÿ=ÿÿÿÿ7.41
      ÿÿÿÿÿÿÿÿÿProbÿ>ÿchi2ÿ=ÿÿÿÿ0.1159

      .ÿ
      .ÿexit

      endÿofÿdo-file


      .


      The method above assumes that the proportions are not independent. If that's not the case, then come back. (As Bruce mentions, your questions is a little incomplete.)

      Comment


      • #4
        Hi Bruce,
        I mean the proportion of events for each group x time point combination eg proportion of respondents replying yes to a specific question at baseline compared to those responding yes to the same question one year later. Then comparing if the difference in proportions between baseline and one year are significantly different across four groups?
        Thank you both for responding

        Comment

        Working...
        X