Announcement

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

  • Binary outcomes over time

    I have a binary outcome (yes/no= 1/0) over 10 survey rounds of data; I'd like to display trends in proportion of a 'yes' outcome over time ... variables = COVID_knowledge_yn (binary) and surveyround (numeric, 1-10) ... would this be a Kruskal Wallis test? Advice on how to display this graphically? I'm striking out with a simple scatter plot.

  • #2
    Grace: You have 10 outcomes for each individual? How many individuals?

    Comment


    • #3
      Or you have a different sample of individuals each time?

      Comment


      • #4
        I have a different sample of individuals each time, but from the same market place (same primary sampling unit)

        Comment


        • #5
          You have data from one market? Then that’s your population, not PSU. The market would be the PSU if you first sample many markets and then sampled within each market.

          Comment


          • #6
            I would just run a regression of your outcome on the wave dummies and look at the pattern.

            Code:
            knowledge i.wave, vce(robust)

            Comment


            • #7
              I have data from two markets, where we randomly sample individuals, and we revisit the same two markets every week

              Comment


              • #8
                Is there any reason to treat the markets separately? If not, do what I said and look at the F test.

                Comment


                • #9
                  No, I've tested assumptions that their results don't significantly vary. Do you have advice on how to display this graphically (change in proportions over time)? I'm interested in a line graph fitted model with x axis represented Round 1- XX, but I'm having a tough time getting proportion of responses to display.

                  Comment


                  • #10
                    Originally posted by Grace Heymsfield View Post
                    Do you have advice on how to display this graphically (change in proportions over time)?
                    You could try something like the following. (Begin at the "Begin here" comment.)

                    .ÿ
                    .ÿversionÿ16.1

                    .ÿ
                    .ÿclearÿ*

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

                    .ÿ
                    .ÿquietlyÿsetÿobsÿ10000

                    .ÿgenerateÿbyteÿCOVID_knowledge_ynÿ=ÿruniform()ÿ<ÿ0.5

                    .ÿgenerateÿbyteÿsurveyroundÿ=ÿmod(_n,ÿ10)ÿ+ÿ1

                    .ÿ
                    .ÿ*
                    .ÿ*ÿBeginÿhere
                    .ÿ*
                    .ÿglmÿCOVID_knowledge_ynÿi.surveyround,ÿfamily(binomial)ÿlink(logit)ÿnolog

                    GeneralizedÿlinearÿmodelsÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿobsÿÿÿ=ÿÿÿÿÿ10,000
                    Optimizationÿÿÿÿÿ:ÿMLÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿResidualÿdfÿÿÿÿÿ=ÿÿÿÿÿÿ9,990
                    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿScaleÿparameterÿ=ÿÿÿÿÿÿÿÿÿÿ1
                    Devianceÿÿÿÿÿÿÿÿÿ=ÿÿÿ13857.1625ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ(1/df)ÿDevianceÿ=ÿÿÿ1.387103
                    Pearsonÿÿÿÿÿÿÿÿÿÿ=ÿÿÿÿÿÿÿÿ10000ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ(1/df)ÿPearsonÿÿ=ÿÿÿ1.001001

                    Varianceÿfunction:ÿV(u)ÿ=ÿu*(1-u)ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ[Bernoulli]
                    Linkÿfunctionÿÿÿÿ:ÿg(u)ÿ=ÿln(u/(1-u))ÿÿÿÿÿÿÿÿÿÿÿÿÿ[Logit]

                    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿAICÿÿÿÿÿÿÿÿÿÿÿÿÿ=ÿÿÿ1.387716
                    Logÿlikelihoodÿÿÿ=ÿ-6928.581252ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿBICÿÿÿÿÿÿÿÿÿÿÿÿÿ=ÿÿ-78154.14

                    ------------------------------------------------------------------------------------
                    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ|ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿOIM
                    COVID_knowledge_ynÿ|ÿÿÿÿÿÿCoef.ÿÿÿStd.ÿErr.ÿÿÿÿÿÿzÿÿÿÿP>|z|ÿÿÿÿÿ[95%ÿConf.ÿInterval]
                    -------------------+----------------------------------------------------------------
                    ÿÿÿÿÿÿÿsurveyroundÿ|
                    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ2ÿÿ|ÿÿ-.1040272ÿÿÿ.0894746ÿÿÿÿ-1.16ÿÿÿ0.245ÿÿÿÿ-.2793942ÿÿÿÿ.0713398
                    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ3ÿÿ|ÿÿ-.0120035ÿÿÿÿ.089456ÿÿÿÿ-0.13ÿÿÿ0.893ÿÿÿÿ-.1873341ÿÿÿÿ.1633271
                    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ4ÿÿ|ÿÿ-.0400053ÿÿÿ.0894517ÿÿÿÿ-0.45ÿÿÿ0.655ÿÿÿÿ-.2153274ÿÿÿÿ.1353167
                    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ5ÿÿ|ÿÿ-.0360053ÿÿÿ.0894518ÿÿÿÿ-0.40ÿÿÿ0.687ÿÿÿÿ-.2113275ÿÿÿÿ.1393169
                    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ6ÿÿ|ÿÿÿ.0120064ÿÿÿ.0894668ÿÿÿÿÿ0.13ÿÿÿ0.893ÿÿÿÿ-.1633453ÿÿÿÿ.1873581
                    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ7ÿÿ|ÿÿÿ.0240165ÿÿÿ.0894746ÿÿÿÿÿ0.27ÿÿÿ0.788ÿÿÿÿ-.1513504ÿÿÿÿ.1993835
                    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ8ÿÿ|ÿÿ-.1280622ÿÿÿÿ.089495ÿÿÿÿ-1.43ÿÿÿ0.152ÿÿÿÿ-.3034692ÿÿÿÿ.0473448
                    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ9ÿÿ|ÿÿ-.0120035ÿÿÿÿ.089456ÿÿÿÿ-0.13ÿÿÿ0.893ÿÿÿÿ-.1873341ÿÿÿÿ.1633271
                    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ10ÿÿ|ÿÿ-.0040014ÿÿÿ.0894589ÿÿÿÿ-0.04ÿÿÿ0.964ÿÿÿÿ-.1793377ÿÿÿÿ.1713348
                    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ|
                    ÿÿÿÿÿÿÿÿÿÿÿÿÿ_consÿ|ÿÿÿ.0400053ÿÿÿ.0632582ÿÿÿÿÿ0.63ÿÿÿ0.527ÿÿÿÿ-.0839785ÿÿÿÿ.1639891
                    ------------------------------------------------------------------------------------

                    .ÿtestparmÿi.surveyround

                    ÿ(ÿ1)ÿÿ[COVID_knowledge_yn]2.surveyroundÿ=ÿ0
                    ÿ(ÿ2)ÿÿ[COVID_knowledge_yn]3.surveyroundÿ=ÿ0
                    ÿ(ÿ3)ÿÿ[COVID_knowledge_yn]4.surveyroundÿ=ÿ0
                    ÿ(ÿ4)ÿÿ[COVID_knowledge_yn]5.surveyroundÿ=ÿ0
                    ÿ(ÿ5)ÿÿ[COVID_knowledge_yn]6.surveyroundÿ=ÿ0
                    ÿ(ÿ6)ÿÿ[COVID_knowledge_yn]7.surveyroundÿ=ÿ0
                    ÿ(ÿ7)ÿÿ[COVID_knowledge_yn]8.surveyroundÿ=ÿ0
                    ÿ(ÿ8)ÿÿ[COVID_knowledge_yn]9.surveyroundÿ=ÿ0
                    ÿ(ÿ9)ÿÿ[COVID_knowledge_yn]10.surveyroundÿ=ÿ0

                    ÿÿÿÿÿÿÿÿÿÿÿchi2(ÿÿ9)ÿ=ÿÿÿÿ5.53
                    ÿÿÿÿÿÿÿÿÿProbÿ>ÿchi2ÿ=ÿÿÿÿ0.7861

                    .ÿ
                    .ÿquietlyÿmarginsÿsurveyround

                    .ÿmarginsplotÿ,ÿxdimension(surveyround)ÿ///
                    >ÿÿÿÿÿÿÿÿÿlevel(50)ÿ///
                    >ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿxtitle(SurveyÿRound)ÿ///
                    >ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿytitle(COVIDÿKnowledgeÿ(ProportionÿAffirmative))ÿ///
                    >ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿylabel(ÿ,ÿformat("%4.2f")ÿangle(horizontal)ÿnogrid)ÿ///
                    >ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿtitle("")

                    ÿÿVariablesÿthatÿuniquelyÿidentifyÿmargins:ÿsurveyround

                    .ÿquietlyÿgraphÿexportÿck.png

                    .ÿ
                    .ÿexit

                    endÿofÿdo-file


                    .


                    Click image for larger version

Name:	ck.png
Views:	1
Size:	34.8 KB
ID:	1585307

                    Comment


                    • #11
                      Just to add to Joseph's helpful reply: You will get exactly the same fitted values as a linear regression. All estimates are simply the cell proportions of "Yes" by year. In a saturated model, all predicted values are the same: linear, logit, probit, and so on.

                      Comment


                      • #12
                        Hi there,

                        Merry Christmas and Happy New Year

                        I am new to STATA and I have population based prevalence rate (with 95% CI) for a disease for each year for 10 years (2005-2014) , what syntax in Stata I can use to assess whether there is a trend or not? Is it possible to make a graph for this trend with 95% CI?

                        Best regards
                        Last edited by Hafi Saad; 26 Dec 2020, 06:17.

                        Comment

                        Working...
                        X