Announcement

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

  • repeated measures & nested ANOVA

    I have a dataset in long format where each eye had the same measurement (a continuous variable) taken by 3 different machines. Some subjects have measurements on both the right and left eye, while others have measurements on just 1 of their 2 eyes. I would like to compare the measurements of eyes that are taken by the 3 machines to see if they are different, and also reflect the fact that the measurements on 2 eyes are nested within subjectid (i.e. right and left eye within the same subject are likely correlated). I am not sure if the code should be the following:

    anova measurement machine subjectid / eye, repeated (machine)

    versus

    anova measurement machine subjectid / eye | subjectid, repeated (machine)

    Thank you for your help

  • #2
    Your best bet is with mixed. Consider something like the following. The top part generates an artificial dataset for illustration. If you believe the data-generating process operating in your study is different from what is shown, then modify your mixed syntax accordingly.
    Code:
    version 15.1
    
    clear *
    
    set seed `=strreverse("1461758")'
    
    quietly set obs 250
    generate int pid = _n
    generate double pid_u = rnormal()
    
    quietly expand 2
    bysort pid: generate byte eye = _n
    generate double eye_u = rnormal()
    
    forvalues mac = 1/3 {
        generate double mea`mac' = ///
            pid_u + ///
            0 * eye + /// dominance
            eye_u + ///
            (`mac' - 2) / 10 + /// machines made by mere mortals cannot be perfectly identical
            0 * eye * `mac' + /// interaction of machine and dominant eye
                rnormal() // homoscedastic
    }
    
    quietly drop if runiform() > 0.95 // ca. 5% unilateral measurements, completely at random
    
    quietly reshape long mea, i(pid eye) j(mac)
    
    *
    * Begin here
    *
    mixed mea i.mac##i.eye || pid: || eye: , nolrtest nolog
    
    testparm i.mac
    
    exit
    Unless your three machines are identical in all respects, measurements of eyes that are taken by the three machines are different. They have to be. Maybe your question is actually whether the measurements by the three machines differ by more than some threshold.

    Comment


    • #3
      Thank you. I agree and I actually was more familiar with the mixed command than the repeated measures anova but for some reason several papers have used the repeated measures anova to compare devices so I was trying to understand the syntax but I agree perhaps it isn't appropriate here.

      If instead I had three measurements taken by the same machine, and was using the anova, what is the main difference if I use the subjectid / eye | subjectid syntax as opposed to just subjectid / eye?

      Comment

      Working...
      X