Announcement

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

  • Repeated ordinal dependent variable with ordinal independent

    I have a long format data set with a repeated by year ordinal dependent variable Y (0=mild, 1=moderate, 2=severe), the repeated factor year (0=2014, 1=2016) and centre (1, 2, 3, 4). I would like to test the marginal homogeneity in the variable centre. What I’m doing is:
    use dataset_long, clear
    xtset id year
    ologit Y i.centre##year b4.i.centre

    Obtaining (cut points omitted)

    Y Coef. Std. Err. z P>z [95% Conf. Interval]
    centre
    1 -.1290855 .3169848 -0.41 0.684 -.7503643 .4921933
    2 -.5908961 .2714226 -2.18 0.029 -1.122875 -.0589175
    3 -.1446371 .3012552 -0.48 0.631 -.7350864 .4458122
    1.year -.760835 .2815766 -2.70 0.007 -1.312715 -.2089551
    centre#year
    1 1 | 1.094596 .4460686 2.45 0.014 .2203171 1.968874
    2 1 | .8680099 .3843708 2.26 0.024 .1146569 1.621363
    3 1 | 1.053251 .4283335 2.46 0.014 .2137328 1.892769

    Could someone tell me if this code is correct? If so, I would appreciate if you may indicate me some reference for interpreting centre#year.
    Thank you very much.

  • Jorge Ruiz Moreno
    replied
    Thank you very much Joseph

    Leave a comment:


  • Joseph Coveney
    replied
    Originally posted by Jorge Ruiz Moreno View Post
    How to tell Stata that this is a panel (repeated measures) dataset?
    Maybe something like that below. Like Clyde, I'm not sure what you mean "to test the marginal homogeneity in the variable centre". I gave it my best guess. Begin at the "Begin here" comment.

    .ÿversionÿ15.1

    .ÿ
    .ÿclearÿ*

    .ÿ
    .ÿprogramÿdefineÿgrologit
    ÿÿ1.ÿÿÿÿÿÿÿÿÿversionÿ15.1
    ÿÿ2.ÿÿÿÿÿÿÿÿÿsyntaxÿvarname(numeric)ÿ,ÿGenerate(name)ÿCuts(numlist)ÿ[Start(integerÿ1)]
    ÿÿ3.ÿ
    .ÿÿÿÿÿÿÿÿÿlocalÿindexÿ1
    ÿÿ4.ÿÿÿÿÿÿÿÿÿforeachÿcutÿofÿnumlistÿ`cuts'ÿ{
    ÿÿ5.ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿtempvarÿcut`index'
    ÿÿ6.ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿgenerateÿdoubleÿ`cut`index''ÿ=ÿinvlogit(`varlist'ÿ+ÿ`cut')
    ÿÿ7.ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿlocalÿcut_listÿ`cut_list'ÿ`cut`index''
    ÿÿ8.ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿlocalÿ++index
    ÿÿ9.ÿÿÿÿÿÿÿÿÿ}
    ÿ10.ÿ
    .ÿÿÿÿÿÿÿÿÿtempvarÿrandu
    ÿ11.ÿÿÿÿÿÿÿÿÿgenerateÿdoubleÿ`randu'ÿ=ÿruniform()
    ÿ12.ÿ
    .ÿÿÿÿÿÿÿÿÿgenerateÿbyteÿ`generate'ÿ=ÿ`start'
    ÿ13.ÿÿÿÿÿÿÿÿÿforeachÿcutÿofÿlocalÿcut_listÿ{
    ÿ14.ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿlocalÿ++start
    ÿ15.ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿquietlyÿreplaceÿ`generate'ÿ=ÿ`start'ÿifÿ`randu'ÿ>ÿ`cut'
    ÿ16.ÿÿÿÿÿÿÿÿÿ}
    ÿ17.ÿend

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

    .ÿ
    .ÿ//ÿcentres
    .ÿquietlyÿsetÿobsÿ4

    .ÿgenerateÿbyteÿcidÿ=ÿ_n

    .ÿ
    .ÿ//ÿpersonsÿwithÿanÿunfavorableÿevent
    .ÿquietlyÿexpandÿ250

    .ÿgenerateÿintÿpidÿ=ÿ_n

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

    .ÿ
    .ÿ//ÿtheÿrepeatedÿfactorÿyear
    .ÿquietlyÿexpandÿ2

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

    .ÿlabelÿdefineÿYearsÿ1ÿ2014ÿ2ÿ2016

    .ÿlabelÿvaluesÿtimÿYears

    .ÿ
    .ÿ//ÿordinalÿdependentÿvariableÿY
    .ÿgenerateÿdoubleÿxbÿ=ÿ///
    >ÿÿÿÿÿÿÿÿÿ0ÿ*ÿcidÿ+ÿ///
    >ÿÿÿÿÿÿÿÿÿpid_uÿ+ÿ///
    >ÿÿÿÿÿÿÿÿÿ0ÿ*ÿtim

    .ÿlocalÿthresholdÿ=ÿ_piÿ/ÿsqrt(3)

    .ÿgrologitÿxb,ÿg(out)ÿc(-`threshold'ÿ`threshold')ÿs(0)

    .ÿlabelÿdefineÿSeveritiesÿ0ÿMildÿ1ÿModerateÿ2ÿSevere

    .ÿlabelÿvaluesÿoutÿSeverities

    .ÿ
    .ÿ*
    .ÿ*ÿBeginÿhere
    .ÿ*
    .ÿmeologitÿoutÿi.cidÿi.timÿ||ÿpid:ÿ,ÿnolrtestÿnolog

    Mixed-effectsÿologitÿregressionÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿobsÿÿÿÿÿ=ÿÿÿÿÿÿ2,000
    Groupÿvariable:ÿÿÿÿÿÿÿÿÿÿÿÿÿpidÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿgroupsÿÿ=ÿÿÿÿÿÿ1,000

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

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

    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿWaldÿchi2(4)ÿÿÿÿÿÿ=ÿÿÿÿÿÿÿ2.34
    Logÿlikelihoodÿ=ÿ-1783.7521ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿProbÿ>ÿchi2ÿÿÿÿÿÿÿ=ÿÿÿÿÿ0.6738
    ------------------------------------------------------------------------------
    ÿÿÿÿÿÿÿÿÿoutÿ|ÿÿÿÿÿÿCoef.ÿÿÿStd.ÿErr.ÿÿÿÿÿÿzÿÿÿÿP>|z|ÿÿÿÿÿ[95%ÿConf.ÿInterval]
    -------------+----------------------------------------------------------------
    ÿÿÿÿÿÿÿÿÿcidÿ|
    ÿÿÿÿÿÿÿÿÿÿ2ÿÿ|ÿÿÿ.1301819ÿÿÿ.1603452ÿÿÿÿÿ0.81ÿÿÿ0.417ÿÿÿÿ-.1840889ÿÿÿÿ.4444528
    ÿÿÿÿÿÿÿÿÿÿ3ÿÿ|ÿÿ-.0985216ÿÿÿ.1602031ÿÿÿÿ-0.61ÿÿÿ0.539ÿÿÿÿ-.4125139ÿÿÿÿ.2154708
    ÿÿÿÿÿÿÿÿÿÿ4ÿÿ|ÿÿÿ.0647923ÿÿÿ.1605154ÿÿÿÿÿ0.40ÿÿÿ0.686ÿÿÿÿ-.2498122ÿÿÿÿ.3793968
    ÿÿÿÿÿÿÿÿÿÿÿÿÿ|
    ÿÿÿÿÿÿÿÿÿtimÿ|
    ÿÿÿÿÿÿÿ2016ÿÿ|ÿÿ-.0325286ÿÿÿ.0941207ÿÿÿÿ-0.35ÿÿÿ0.730ÿÿÿÿ-.2170017ÿÿÿÿ.1519445
    -------------+----------------------------------------------------------------
    ÿÿÿÿÿÿÿ/cut1ÿ|ÿÿ-1.716974ÿÿÿ.1381387ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ-1.987721ÿÿÿ-1.446227
    ÿÿÿÿÿÿÿ/cut2ÿ|ÿÿÿ1.893418ÿÿÿ.1411132ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ1.616841ÿÿÿÿ2.169994
    -------------+----------------------------------------------------------------
    pidÿÿÿÿÿÿÿÿÿÿ|
    ÿÿÿvar(_cons)|ÿÿÿ.9954363ÿÿÿ.2174425ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ.6487502ÿÿÿÿ1.527388
    ------------------------------------------------------------------------------

    .ÿ
    .ÿ/*ÿRejectÿnullÿhypothesisÿofÿheterogeneityÿatÿαÿ=ÿ5%ÿinÿfavorÿofÿalternative
    >ÿÿÿÿhypothesisÿofÿhomogeneityÿÿeachÿandÿeveryÿ90%ÿCIÿcontainedÿwithin,ÿsay,ÿ½ÿandÿ2ÿ*/
    .ÿforvaluesÿiÿ=ÿ1/3ÿ{
    ÿÿ2.ÿÿÿÿÿÿÿÿÿquietlyÿlincomÿ_b[4.cid]ÿ-ÿ_b[`i'.cid],ÿlevel(90)ÿor
    ÿÿ3.ÿÿÿÿÿÿÿÿÿdisplayÿinÿsmclÿasÿtextÿ"Centreÿ`i':ÿ"ÿasÿresultÿ%04.2fÿr(lb),ÿ%04.2fÿr(ub)
    ÿÿ4.ÿ}
    Centreÿ1:ÿ0.82ÿ1.39
    Centreÿ2:ÿ0.72ÿ1.22
    Centreÿ3:ÿ0.90ÿ1.53

    .ÿ
    .ÿ/*ÿTestÿforÿhomogeneityÿif,ÿsay,ÿtheÿcentersÿwereÿinterventionsÿwhereÿequality
    >ÿÿÿÿisÿtenableÿandÿinterestingÿ*/
    .ÿtestparmÿi.cid

    ÿ(ÿ1)ÿÿ[out]2.cidÿ=ÿ0
    ÿ(ÿ2)ÿÿ[out]3.cidÿ=ÿ0
    ÿ(ÿ3)ÿÿ[out]4.cidÿ=ÿ0

    ÿÿÿÿÿÿÿÿÿÿÿchi2(ÿÿ3)ÿ=ÿÿÿÿ2.22
    ÿÿÿÿÿÿÿÿÿProbÿ>ÿchi2ÿ=ÿÿÿÿ0.5281

    .ÿ//ÿor
    .ÿestimatesÿstoreÿFull

    .ÿquietlyÿmeologitÿoutÿi.timÿ||ÿpid:

    .ÿlrtestÿFull

    Likelihood-ratioÿtestÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿLRÿchi2(3)ÿÿ=ÿÿÿÿÿÿ2.22
    (Assumption:ÿ.ÿnestedÿinÿFull)ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿProbÿ>ÿchi2ÿ=ÿÿÿÿ0.5275

    .ÿ
    .ÿexit

    endÿofÿdo-file


    .

    Leave a comment:


  • Jorge Ruiz Moreno
    replied
    Dear Clyde,
    Regarding “clogit” I did not mean Stata clogit command. I meant the cumulative logits of cumulative probabilities log[P(moderate, severe)/P(mild)] and log[P(severe)/P(mild, moderate)] following (Y>m)/P(Y≤m).
    Thank you!

    Leave a comment:


  • Clyde Schechter
    replied
    1. Regarding clogits, when you say "odds of being above vs. at or below any of the the levels of Y", just to be sure, do you mean P(Y>m)/P(Y≤m).
    Yes, that is what I mean.

    If so, in this case we would have two clogits with the unfavorable event in the numerator
    I have no idea what this means. What does clogit have to do with this?

    log[P(mod, sev)/P(mild)]
    and
    log[P(sev)/P(mild, mod)]
    In the -ologit- model, there is a constraint (assumption) that these two are equal, so there is only one such probability ratio.

    My interpretation of 1 1: the effects of year 2016 (year = 1) over distribution of Y in centre 1 is 2.98 times higher than in center 4. Is this interpretation correct?
    It is correct if by effect you mean ratio of odds ratios.

    My interpretation of 0 1: for year 2014 in centre 1, we expect to find 0.88 persons with an unfaforable event for every person without it
    My interpretation of 1 1: for 2016 in centre 1 we expect to find 1.22 persons with an unfavorable event for every person without it
    Unfavorable event refers to P(Y>m)/P(Y≤m)
    Are these interpretations correct?
    Correct.

    ​​​​​​​

    Leave a comment:


  • Jorge Ruiz Moreno
    replied
    Clyde and Joseph, thank you very much for the answers.

    After reflecting:

    1. Regarding clogits, when you say "odds of being above vs. at or below any of the the levels of Y", just to be sure, do you mean P(Y>m)/P(Y≤m). If so, in this case we would have two clogits with the unfavorable event in the numerator
    log[P(mod, sev)/P(mild)]
    and
    log[P(sev)/P(mild, mod)]

    2. After exponentiate coefficients I have obtained odds ratio (centre=4 as reference):

    Code:
    ologit Y i.centre##year b4.i.centre, or
    (excerp)
    Y Odds Ratio Std. Err. z P>z [95% Conf. Interval]
    centre#year
    1 1 2.987974 1.332842 2.45 0.014 1.246472 7.162607
    2 1 2.382165 .9156349 2.26 0.024 1.121489 5.059982
    3 1 2.866956 1.228013 2.46 0.014 1.238292 6.637724


    My interpretation of 1 1: the effects of year 2016 (year = 1) over distribution of Y in centre 1 is 2.98 times higher than in center 4. Is this interpretation correct?

    3. On the other hand I used the margins command for obtaining odds for combinations of year and centre (following Maarten L.Buis, STATA tip 87: Interpretation of interactions in nonlinear models, The Stata Journal (2010) 10, Number 2, pp. 305-308)

    Code:
    margins, over(year centre) expression(exp(xb())) post
    Delta-method
    Margin Std. Err. z P>z [95% Conf. Interval]
    year#centre
    0 1 .8788988 .2785976 3.15 0.002 .3328576 1.42494
    0 2 .5538308 .1503222 3.68 0.000 .2592047 .8484569
    0 3 .8653362 .260687 3.32 0.001 .3543991 1.376273
    0 4 1 . . . . .
    1 1 1.227126 .3833175 3.20 0.001 .4758378 1.978415
    1 2 .6164851 .1679434 3.67 0.000 .287322 .9456481
    1 3 1.159256 .3513713 3.30 0.001 .4705814 1.847931
    1 4 .4672761 .131574 3.55 0.000 .2093958 .7251564


    My interpretation of 0 1: for year 2014 in centre 1, we expect to find 0.88 persons with an unfaforable event for every person without it
    My interpretation of 1 1: for 2016 in centre 1 we expect to find 1.22 persons with an unfavorable event for every person without it
    Unfavorable event refers to P(Y>m)/P(Y≤m)
    Are these interpretations correct?

    4. As pointed out by Joseph it is not necessary to use xtset before ologit command. Then, How to tell Stata that this is a panel (repeated measures) dataset?

    Again thank you for your valuable help.

    Leave a comment:


  • Joseph Coveney
    replied
    Just be aware that
    Code:
    xtset id year
    doesn't do much with ologit

    Leave a comment:


  • Clyde Schechter
    replied
    Your code looks like a correct implementation of an ordinal logistic regression of outcome Y with predictors center and year and their interaction.

    I am not sure what you mean by "test the marginal homogeneity in the variable centre." If you wish to test the hypothesis that the marginal distribution of Y is the same in all four centers, you can do that by following your -ologit- command with:

    Code:
    margins center, contrast
    The overall test of homogeneity will be in the output row that is called "Joint"

    The interaction terms tell you whether the effect of center on the distribution of Y differs between the two years. (Or, equivalently, they tell you whether the effect of year on the distribution Y differs among the centers.) The direct interpretation of the individual interaction term coefficients is somewhat complicated because the -ologit- model is, itself, somewhat complicated to explain. If you exponentiate each coefficient you will get ratios (2016 vs 2014) of odds ratios for each center. The term "odds ratio" in an ordinal logistic model refers to the odds of being above vs. at or below any of the the levels of Y in association with a unit difference in the predictor. In this case, each predictor is an indicator for a center, so it refers to the odds of being above vs. at or below any of the levels of Y in association with being in that center vs being in center 4 (the reference center).

    Leave a comment:

Working...
X