Announcement

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

  • Comparing proportions between separate variables

    Hi, I have a dataset for intraoperative radiotherapy, and have data for postoperative complications. There are n=113 patients, and for each patient I have a variable for wound complications, GI complications, GU complications, and neuro complications. I have each variable labelled as 0 for no complication, or 1 for complication. Additionally, for each 1 of these variables (wound, GI, GU, neuro), I think that wound complications have a higher chance of being severe complications, so I made a variables called severewoundcomp, severegicomp, etc that are for patients with that type of complication, labelled 1 if it was severe and 0 if it was not severe. I am trying to compare the proportion of complications that are severe in wound complications compared to GI, GU and neuro complications and see if this is significant. prtest and ttest don't work because they are different variables, and those compare proportions between groups within the same variable. Also, I cannot make a variable called severecomp and label 1 for severe complication and 0 for no severe complication because the same patient may have had both a wound and gi complication, but 1 was severe and 1 was not. Is it possible to do this?

  • #2
    prtest and ttest don't work because they are different variables
    You can do a matched pairs t-test. The help gives the example

    Code:
    webuse fuel, clear
    ttest mpg1==mpg2
    Technically you'll be violating the assumptions of the t-test but it usually doesn't matter much if you have a decent sized sample.
    -------------------------------------------
    Richard Williams, Notre Dame Dept of Sociology
    Stata Version: 17.0 MP (2 processor)

    EMAIL: [email protected]
    WWW: https://www3.nd.edu/~rwilliam

    Comment


    • #3
      An epidemiologist can correct me if I am wrong, but I think you could also use the mcc command.
      -------------------------------------------
      Richard Williams, Notre Dame Dept of Sociology
      Stata Version: 17.0 MP (2 processor)

      EMAIL: [email protected]
      WWW: https://www3.nd.edu/~rwilliam

      Comment


      • #4
        As to your first problem, you can compare proportion of wound complications that are severe to corresponding proportions of each of the other complications using pr (see output below), but you would have to treat the proportions as independent, which ignores the inherent correlations induced by clustering on patient. This is because a patient with a severe GI complication might very well not have any wound complication at all, severe or otherwise. So you might want to think through just what you're trying to get at.

        For your second problem, I'm not sure that I follow you, but it seems as if you want a summary indicator variable for whether a patient has one or more severe complications. If that's the case, then see below.

        .ÿversionÿ14.1

        .ÿ
        .ÿclearÿ*

        .ÿsetÿmoreÿoff

        .ÿquietlyÿsetÿseedÿ`=date("2016-03-19",ÿ"YMD")'

        .ÿ
        .ÿquietlyÿsetÿobsÿ119

        .ÿgenerateÿintÿpidÿ=ÿ_n

        .ÿ
        .ÿtempnameÿrandu

        .ÿforeachÿvarÿofÿnewlistÿwoundÿgiÿguÿneuroÿ{
        ÿÿ2.ÿÿÿÿÿÿÿÿÿscalarÿdefineÿ`randu'ÿ=ÿruniform()ÿ/ÿ2
        ÿÿ3.ÿÿÿÿÿÿÿÿÿgenerateÿbyteÿ`var'ÿ=ÿruniform()ÿ<ÿ`randu'
        ÿÿ4.ÿÿÿÿÿÿÿÿÿgenerateÿbyteÿsevere_`var'ÿ=ÿruniform()ÿ>ÿ0.5ÿ&ÿ`var'
        ÿÿ5.ÿ}

        .ÿ
        .ÿ//ÿForÿexample,ÿaÿquarterÿofÿallÿpatientsÿhaveÿaÿwoundÿcomplicationÿofÿwhichÿtwo-fifthsÿareÿsevere
        .ÿtabulateÿwoundÿsevere_wound,ÿmissingÿrowÿcol

        +-------------------+
        |ÿKeyÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ|
        |-------------------|
        |ÿÿÿÿÿfrequencyÿÿÿÿÿ|
        |ÿÿrowÿpercentageÿÿÿ|
        |ÿcolumnÿpercentageÿ|
        +-------------------+

        ÿÿÿÿÿÿÿÿÿÿÿ|ÿÿÿÿÿsevere_wound
        ÿÿÿÿÿwoundÿ|ÿÿÿÿÿÿÿÿÿ0ÿÿÿÿÿÿÿÿÿÿ1ÿ|ÿÿÿÿÿTotal
        -----------+----------------------+----------
        ÿÿÿÿÿÿÿÿÿ0ÿ|ÿÿÿÿÿÿÿÿ91ÿÿÿÿÿÿÿÿÿÿ0ÿ|ÿÿÿÿÿÿÿÿ91ÿ
        ÿÿÿÿÿÿÿÿÿÿÿ|ÿÿÿÿ100.00ÿÿÿÿÿÿÿ0.00ÿ|ÿÿÿÿ100.00ÿ
        ÿÿÿÿÿÿÿÿÿÿÿ|ÿÿÿÿÿ84.26ÿÿÿÿÿÿÿ0.00ÿ|ÿÿÿÿÿ76.47ÿ
        -----------+----------------------+----------
        ÿÿÿÿÿÿÿÿÿ1ÿ|ÿÿÿÿÿÿÿÿ17ÿÿÿÿÿÿÿÿÿ11ÿ|ÿÿÿÿÿÿÿÿ28ÿ
        ÿÿÿÿÿÿÿÿÿÿÿ|ÿÿÿÿÿ60.71ÿÿÿÿÿÿ39.29ÿ|ÿÿÿÿ100.00ÿ
        ÿÿÿÿÿÿÿÿÿÿÿ|ÿÿÿÿÿ15.74ÿÿÿÿÿ100.00ÿ|ÿÿÿÿÿ23.53ÿ
        -----------+----------------------+----------
        ÿÿÿÿÿTotalÿ|ÿÿÿÿÿÿÿ108ÿÿÿÿÿÿÿÿÿ11ÿ|ÿÿÿÿÿÿÿ119ÿ
        ÿÿÿÿÿÿÿÿÿÿÿ|ÿÿÿÿÿ90.76ÿÿÿÿÿÿÿ9.24ÿ|ÿÿÿÿ100.00ÿ
        ÿÿÿÿÿÿÿÿÿÿÿ|ÿÿÿÿ100.00ÿÿÿÿÿ100.00ÿ|ÿÿÿÿ100.00ÿ


        .ÿ
        .ÿ*
        .ÿ*ÿBeginÿhere
        .ÿ*
        .ÿ
        .ÿ/*ÿ"Iÿamÿtryingÿtoÿcompareÿtheÿproportionÿofÿcomplications
        >ÿÿÿÿthatÿareÿsevereÿinÿwoundÿcomplications
        >ÿÿÿÿcomparedÿtoÿGI,ÿGUÿandÿneuroÿ[severe]ÿcomplications
        >ÿÿÿÿandÿseeÿifÿthisÿisÿsignificant."ÿ*/
        .ÿsummarizeÿsevere_woundÿifÿwound,ÿmeanonly

        .ÿlocalÿwound_prÿ=ÿr(mean)

        .ÿlocalÿwound_nÿ=ÿr(N)

        .ÿ
        .ÿforeachÿvarÿofÿvarlistÿgiÿguÿneuroÿ{
        ÿÿ2.ÿÿÿÿÿÿÿÿÿdisplayÿinÿsmclÿasÿtextÿ_newline(1)ÿ"Severeÿ`var'ÿvsÿsevereÿwoundÿproportions"
        ÿÿ3.ÿÿÿÿÿÿÿÿÿsummarizeÿsevere_`var'ÿifÿ`var',ÿmeanonly
        ÿÿ4.ÿÿÿÿÿÿÿÿÿprtestiÿ`wound_n'ÿ`wound_pr'ÿ`=r(N)'ÿ`=r(mean)'
        ÿÿ5.ÿ}

        Severeÿgiÿvsÿsevereÿwoundÿproportions

        Two-sampleÿtestÿofÿproportionsÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿx:ÿNumberÿofÿobsÿ=ÿÿÿÿÿÿÿ28
        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿy:ÿNumberÿofÿobsÿ=ÿÿÿÿÿÿÿ35
        ------------------------------------------------------------------------------
        ÿÿÿÿVariableÿ|ÿÿÿÿÿÿÿMeanÿÿÿStd.ÿErr.ÿÿÿÿÿÿzÿÿÿÿP>|z|ÿÿÿÿÿ[95%ÿConf.ÿInterval]
        -------------+----------------------------------------------------------------
        ÿÿÿÿÿÿÿÿÿÿÿxÿ|ÿÿÿ.3928571ÿÿÿ.0922962ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ.2119599ÿÿÿÿ.5737543
        ÿÿÿÿÿÿÿÿÿÿÿyÿ|ÿÿÿ.4571429ÿÿÿ.0842044ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ.2921053ÿÿÿÿ.6221804
        -------------+----------------------------------------------------------------
        ÿÿÿÿÿÿÿÿdiffÿ|ÿÿ-.0642857ÿÿÿ.1249358ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ-.3091555ÿÿÿÿÿ.180584
        ÿÿÿÿÿÿÿÿÿÿÿÿÿ|ÿÿunderÿHo:ÿÿÿ.1254729ÿÿÿÿ-0.51ÿÿÿ0.608
        ------------------------------------------------------------------------------
        ÿÿÿÿÿÿÿÿdiffÿ=ÿprop(x)ÿ-ÿprop(y)ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿzÿ=ÿÿ-0.5123
        ÿÿÿÿHo:ÿdiffÿ=ÿ0

        ÿÿÿÿHa:ÿdiffÿ<ÿ0ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿHa:ÿdiffÿ!=ÿ0ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿHa:ÿdiffÿ>ÿ0
        ÿPr(Zÿ<ÿz)ÿ=ÿ0.3042ÿÿÿÿÿÿÿÿÿPr(|Z|ÿ>ÿ|z|)ÿ=ÿ0.6084ÿÿÿÿÿÿÿÿÿÿPr(Zÿ>ÿz)ÿ=ÿ0.6958

        Severeÿguÿvsÿsevereÿwoundÿproportions

        Two-sampleÿtestÿofÿproportionsÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿx:ÿNumberÿofÿobsÿ=ÿÿÿÿÿÿÿ28
        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿy:ÿNumberÿofÿobsÿ=ÿÿÿÿÿÿÿ41
        ------------------------------------------------------------------------------
        ÿÿÿÿVariableÿ|ÿÿÿÿÿÿÿMeanÿÿÿStd.ÿErr.ÿÿÿÿÿÿzÿÿÿÿP>|z|ÿÿÿÿÿ[95%ÿConf.ÿInterval]
        -------------+----------------------------------------------------------------
        ÿÿÿÿÿÿÿÿÿÿÿxÿ|ÿÿÿ.3928571ÿÿÿ.0922962ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ.2119599ÿÿÿÿ.5737543
        ÿÿÿÿÿÿÿÿÿÿÿyÿ|ÿÿÿ.4634146ÿÿÿ.0778776ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ.3107774ÿÿÿÿ.6160519
        -------------+----------------------------------------------------------------
        ÿÿÿÿÿÿÿÿdiffÿ|ÿÿ-.0705575ÿÿÿ.1207622ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ-.307247ÿÿÿÿÿ.166132
        ÿÿÿÿÿÿÿÿÿÿÿÿÿ|ÿÿunderÿHo:ÿÿÿ.1215339ÿÿÿÿ-0.58ÿÿÿ0.562
        ------------------------------------------------------------------------------
        ÿÿÿÿÿÿÿÿdiffÿ=ÿprop(x)ÿ-ÿprop(y)ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿzÿ=ÿÿ-0.5806
        ÿÿÿÿHo:ÿdiffÿ=ÿ0

        ÿÿÿÿHa:ÿdiffÿ<ÿ0ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿHa:ÿdiffÿ!=ÿ0ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿHa:ÿdiffÿ>ÿ0
        ÿPr(Zÿ<ÿz)ÿ=ÿ0.2808ÿÿÿÿÿÿÿÿÿPr(|Z|ÿ>ÿ|z|)ÿ=ÿ0.5615ÿÿÿÿÿÿÿÿÿÿPr(Zÿ>ÿz)ÿ=ÿ0.7192

        Severeÿneuroÿvsÿsevereÿwoundÿproportions

        Two-sampleÿtestÿofÿproportionsÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿx:ÿNumberÿofÿobsÿ=ÿÿÿÿÿÿÿ28
        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿy:ÿNumberÿofÿobsÿ=ÿÿÿÿÿÿÿ48
        ------------------------------------------------------------------------------
        ÿÿÿÿVariableÿ|ÿÿÿÿÿÿÿMeanÿÿÿStd.ÿErr.ÿÿÿÿÿÿzÿÿÿÿP>|z|ÿÿÿÿÿ[95%ÿConf.ÿInterval]
        -------------+----------------------------------------------------------------
        ÿÿÿÿÿÿÿÿÿÿÿxÿ|ÿÿÿ.3928571ÿÿÿ.0922962ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ.2119599ÿÿÿÿ.5737543
        ÿÿÿÿÿÿÿÿÿÿÿyÿ|ÿÿÿ.5208333ÿÿÿ.0721061ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ.379508ÿÿÿÿ.6621587
        -------------+----------------------------------------------------------------
        ÿÿÿÿÿÿÿÿdiffÿ|ÿÿ-.1279762ÿÿÿ.1171233ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ-.3575337ÿÿÿÿ.1015813
        ÿÿÿÿÿÿÿÿÿÿÿÿÿ|ÿÿunderÿHo:ÿÿÿ.1187339ÿÿÿÿ-1.08ÿÿÿ0.281
        ------------------------------------------------------------------------------
        ÿÿÿÿÿÿÿÿdiffÿ=ÿprop(x)ÿ-ÿprop(y)ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿzÿ=ÿÿ-1.0778
        ÿÿÿÿHo:ÿdiffÿ=ÿ0

        ÿÿÿÿHa:ÿdiffÿ<ÿ0ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿHa:ÿdiffÿ!=ÿ0ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿHa:ÿdiffÿ>ÿ0
        ÿPr(Zÿ<ÿz)ÿ=ÿ0.1406ÿÿÿÿÿÿÿÿÿPr(|Z|ÿ>ÿ|z|)ÿ=ÿ0.2811ÿÿÿÿÿÿÿÿÿÿPr(Zÿ>ÿz)ÿ=ÿ0.8594

        .ÿ
        .ÿ/*ÿ"Also,ÿIÿcannotÿmakeÿaÿvariableÿcalledÿseverecomp
        >ÿÿÿÿandÿlabelÿ1ÿforÿsevereÿcomplicationÿandÿ0ÿforÿnoÿsevereÿcomplication
        >ÿÿÿÿbecauseÿtheÿsameÿpatientÿmayÿhaveÿhadÿbothÿaÿwoundÿandÿgiÿcomplication,
        >ÿÿÿÿbutÿ1ÿwasÿsevereÿandÿ1ÿwasÿnot.ÿIsÿitÿpossibleÿtoÿdoÿthis?"ÿ*/
        .ÿegenÿbyteÿany_severeÿ=ÿrowmax(severe_*)

        .ÿlabelÿvariableÿany_severeÿ"AtÿLeastÿOneÿComplicationÿisÿSevere"

        .ÿlabelÿdefineÿSevereÿ0ÿ"NoÿSevereÿComplication"ÿ1ÿ"OneÿoreÿMoreÿSevere"

        .ÿlabelÿvaluesÿany_severeÿSevere

        .ÿtabulateÿany_severe,ÿmissing

        ÿÿÿÿÿÿÿÿÿÿAtÿLeastÿOneÿ|
        ComplicationÿisÿSevereÿ|ÿÿÿÿÿÿFreq.ÿÿÿÿÿPercentÿÿÿÿÿÿÿÿCum.
        -----------------------+-----------------------------------
        NoÿSevereÿComplicationÿ|ÿÿÿÿÿÿÿÿÿ58ÿÿÿÿÿÿÿ48.74ÿÿÿÿÿÿÿ48.74
        ÿÿÿOneÿoreÿMoreÿSevereÿ|ÿÿÿÿÿÿÿÿÿ61ÿÿÿÿÿÿÿ51.26ÿÿÿÿÿÿ100.00
        -----------------------+-----------------------------------
        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿTotalÿ|ÿÿÿÿÿÿÿÿ119ÿÿÿÿÿÿ100.00

        .ÿ
        .ÿ//ÿAlternativeÿtoÿassumingÿindependence
        .ÿdropÿany_severe

        .ÿforeachÿvarÿofÿvarlistÿwoundÿgiÿguÿneuroÿ{
        ÿÿ2.ÿÿÿÿÿÿÿÿÿquietlyÿreplaceÿ`var'ÿ=ÿ`var'ÿ+ÿsevere_`var'
        ÿÿ3.ÿÿÿÿÿÿÿÿÿdropÿsevere_`var'
        ÿÿ4.ÿ}

        .ÿ
        .ÿgsemÿ(woundÿ<-ÿM1[pid],ÿoprobit)ÿ///
        >ÿÿÿÿÿÿ(giÿ<-ÿM1[pid],ÿoprobit)ÿ///
        >ÿÿÿÿÿÿÿÿÿÿ(guÿ<-ÿM1[pid],ÿoprobit)ÿ///
        >ÿÿÿÿÿÿÿÿÿÿ(neuroÿ<-ÿM1[pid],ÿoprobit),ÿnocnsreportÿnodvheaderÿnolog

        GeneralizedÿstructuralÿequationÿmodelÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿobsÿÿÿÿÿ=ÿÿÿÿÿÿÿÿ119
        Logÿlikelihoodÿ=ÿ-394.52048

        ------------------------------------------------------------------------------
        ÿÿÿÿÿÿÿÿÿÿÿÿÿ|ÿÿÿÿÿÿCoef.ÿÿÿStd.ÿErr.ÿÿÿÿÿÿzÿÿÿÿP>|z|ÿÿÿÿÿ[95%ÿConf.ÿInterval]
        -------------+----------------------------------------------------------------
        woundÿ<-ÿÿÿÿÿ|
        ÿÿÿÿÿM1[pid]ÿ|ÿÿÿÿÿÿÿÿÿÿ1ÿÿ(constrained)
        -------------+----------------------------------------------------------------
        giÿ<-ÿÿÿÿÿÿÿÿ|
        ÿÿÿÿÿM1[pid]ÿ|ÿÿÿ3.768932ÿÿÿ6.043606ÿÿÿÿÿ0.62ÿÿÿ0.533ÿÿÿÿ-8.076317ÿÿÿÿ15.61418
        -------------+----------------------------------------------------------------
        guÿ<-ÿÿÿÿÿÿÿÿ|
        ÿÿÿÿÿM1[pid]ÿ|ÿÿÿ2.397831ÿÿÿ2.776929ÿÿÿÿÿ0.86ÿÿÿ0.388ÿÿÿÿ-3.044849ÿÿÿÿ7.840511
        -------------+----------------------------------------------------------------
        neuroÿ<-ÿÿÿÿÿ|
        ÿÿÿÿÿM1[pid]ÿ|ÿÿ-2.153218ÿÿÿ2.981632ÿÿÿÿ-0.72ÿÿÿ0.470ÿÿÿÿÿ-7.99711ÿÿÿÿ3.690674
        -------------+----------------------------------------------------------------
        woundÿÿÿÿÿÿÿÿ|
        ÿÿÿÿÿÿÿ/cut1ÿ|ÿÿÿÿÿ.73357ÿÿÿ.1315861ÿÿÿÿÿ5.57ÿÿÿ0.000ÿÿÿÿÿ.4756659ÿÿÿÿ.9914741
        ÿÿÿÿÿÿÿ/cut2ÿ|ÿÿÿ1.351023ÿÿÿ.1713097ÿÿÿÿÿ7.89ÿÿÿ0.000ÿÿÿÿÿ1.015262ÿÿÿÿ1.686784
        -------------+----------------------------------------------------------------
        giÿÿÿÿÿÿÿÿÿÿÿ|
        ÿÿÿÿÿÿÿ/cut1ÿ|ÿÿÿ.6653378ÿÿÿ.2308765ÿÿÿÿÿ2.88ÿÿÿ0.004ÿÿÿÿÿ.2128282ÿÿÿÿ1.117847
        ÿÿÿÿÿÿÿ/cut2ÿ|ÿÿÿ1.367705ÿÿÿ.3973685ÿÿÿÿÿ3.44ÿÿÿ0.001ÿÿÿÿÿ.5888772ÿÿÿÿ2.146533
        -------------+----------------------------------------------------------------
        guÿÿÿÿÿÿÿÿÿÿÿ|
        ÿÿÿÿÿÿÿ/cut1ÿ|ÿÿÿ.4361639ÿÿÿ.1404864ÿÿÿÿÿ3.10ÿÿÿ0.002ÿÿÿÿÿ.1608157ÿÿÿÿ.7115122
        ÿÿÿÿÿÿÿ/cut2ÿ|ÿÿÿ1.095132ÿÿÿÿ.198098ÿÿÿÿÿ5.53ÿÿÿ0.000ÿÿÿÿÿ.7068667ÿÿÿÿ1.483397
        -------------+----------------------------------------------------------------
        neuroÿÿÿÿÿÿÿÿ|
        ÿÿÿÿÿÿÿ/cut1ÿ|ÿÿÿ.2586708ÿÿÿ.1272043ÿÿÿÿÿ2.03ÿÿÿ0.042ÿÿÿÿÿ.0093549ÿÿÿÿ.5079868
        ÿÿÿÿÿÿÿ/cut2ÿ|ÿÿÿ.8697855ÿÿÿÿ.157021ÿÿÿÿÿ5.54ÿÿÿ0.000ÿÿÿÿÿÿÿ.56203ÿÿÿÿ1.177541
        -------------+----------------------------------------------------------------
        ÿvar(M1[pid])|ÿÿÿÿ.037769ÿÿÿ.0879244ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ.0003941ÿÿÿÿ3.619867
        ------------------------------------------------------------------------------

        .ÿ
        .ÿforeachÿcomplicationÿinÿgiÿguÿneuroÿ{
        ÿÿ2.ÿÿÿÿÿÿÿÿÿdisplayÿinÿsmclÿasÿtextÿ_newline(1)ÿ"Severeÿ`complication'ÿvsÿsevereÿwoundÿcomplications"
        ÿÿ3.ÿÿÿÿÿÿÿÿÿtestÿ_b[wound_cut2:_cons]ÿ=ÿ_b[`complication'_cut2:_cons]
        ÿÿ4.ÿ}

        Severeÿgiÿvsÿsevereÿwoundÿcomplications

        ÿ(ÿ1)ÿÿ[wound_cut2]_consÿ-ÿ[gi_cut2]_consÿ=ÿ0

        ÿÿÿÿÿÿÿÿÿÿÿchi2(ÿÿ1)ÿ=ÿÿÿÿ0.00
        ÿÿÿÿÿÿÿÿÿProbÿ>ÿchi2ÿ=ÿÿÿÿ0.9702

        Severeÿguÿvsÿsevereÿwoundÿcomplications

        ÿ(ÿ1)ÿÿ[wound_cut2]_consÿ-ÿ[gu_cut2]_consÿ=ÿ0

        ÿÿÿÿÿÿÿÿÿÿÿchi2(ÿÿ1)ÿ=ÿÿÿÿ1.05
        ÿÿÿÿÿÿÿÿÿProbÿ>ÿchi2ÿ=ÿÿÿÿ0.3049

        Severeÿneuroÿvsÿsevereÿwoundÿcomplications

        ÿ(ÿ1)ÿÿ[wound_cut2]_consÿ-ÿ[neuro_cut2]_consÿ=ÿ0

        ÿÿÿÿÿÿÿÿÿÿÿchi2(ÿÿ1)ÿ=ÿÿÿÿ4.10
        ÿÿÿÿÿÿÿÿÿProbÿ>ÿchi2ÿ=ÿÿÿÿ0.0429

        .ÿ
        .ÿexit

        endÿofÿdo-file


        .


        At the end of the output above, I've shown a possible workaround to the independence assumption for testing differences in severity between wound complications and the others, but I consider it off-the-cuff—you'd want to convince yourself of its legitimacy and correctness before relying on it.
        Last edited by Joseph Coveney; 18 Mar 2016, 20:07.

        Comment


        • #5
          As an epidemiologist, I will confirm Richard's observation that you could also use the mcc command.

          But I see a bigger problem that might impair any test you try to do on these data. You stated that the severe*comp variables are defined only when the complication itself is coded 1. So if you have any people who had only a wound complication or only a GI complication, they would have a missing value for the severe_other_complication variable and would be excluded from either the -ttest- or the -mcc- analysis. (Coding those missing values as zero solves that problem but then creates the new problem that the analysis would now include people who don't have the complication at all.) Consequently your results are only applicable to those who develop both complications. But I think there is real reason to be concerned that people who develop multiple complications are different from those who develop only one, and that the severity of different types of complications might also be different for this subpopulation. I think the more salient question is the contrast of the rate of severe complication conditional on that particular complication occurring.

          To approach that I would organize the data differently. For the purposes of illustration, let's assume your data contains only patient_id, comp_GI, severecomp_GI, comp_wound, and severecomp_wound. So I would do something like this:

          Code:
          reshape long comp severecomp, i(patient_id) j(_type) string
          keep if comp == 1
          assert !missing(severecomp)
          replace _type = substr(_type, 2, .)
          encode _type, gen(type)
          melogit severecomp i.type || patient_id:
          The output for the type variable gives you a test of the difference between GI and wound complications in probability of the complication being severe, and it includes everybody who had a complicatoin of either type. The use of the mixed-effects logit with random intercept for id will lead to a correct calculation of the standard errors taking into account that some of the observations are repeated within patient.

          If you also want estimates of the severe complication rate conditional on the complication being present, you can follow up the -melogit- command with -margins type-.

          Added: crossed in cyberspace with Joseph Coveney's response. His proposal to use -gsem- is interesting, but it looks to me as if it contrasts probabilities of developing a severe complication of different types, but not conditional on actually having that type of complication.
          Last edited by Clyde Schechter; 18 Mar 2016, 20:11.

          Comment

          Working...
          X