Announcement

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

  • ANOVA with more levels of nesting

    I'm having trouble with a nested ANOVA with two levels of nesting. Specifically, I have two treatments (A and B) at two levels each (0, 1 for both A and B), Litters nested within the 4 combination of A and B levels (00, 01, 10, 11), Sex within litters and Animal within Sex and Litter (two littermates per sex per litter). I would like to test the effects of A, B, A#B, with Litter|(A#B) as error term, and Sex, Sex#A, Sex#B, Sex#A#B with Sex#Litter|(A#B) as error term. I would also like to test the effect of Litter on Animal within Sex and Litter. I have generated the variable AB = A*10+B and tried the following models:
    1) anova RESPONSE A B A#B / Litter|A#B Sex Sex#A Sex#B Sex#A#B / Sex#Litter|A#B
    2) anova RESPONSE A B A#B / Litter|(A#B) Sex Sex#A Sex#B Sex#A#B / Sex#Litter|(A#B)
    3) anova RESPONSE A B A#B / Litter|AB Sex Sex#A Sex#B Sex#A#B / Sex#Litter|AB
    I expected equal results, at least from models 2 and 3. Models 1 and 2 give the same results but, unfortunately, they give different results from model 3. In addition, Models 1 and 2 give the same results also when using for example A#Litter|B or B#Litter|A instead of Litter|(A#B) or Litter|A#B, and this is clearly wrong. In any case, I don't' succeed in testing the effect of Litter. How should I do? Any suggestion is really appreciated.
    Thank you very much

  • #2
    Hi, Flavia.

    Have you considered a multilevel model, say, via -mixed- ?

    Comment


    • #3

      Hi, sorry for the delay in replying. I heve seen the mixed procedure, but I could not understand from the manual how to formalize the model, with two levels of nesting (litter and animal within litter), and fixed effects (1) between-litter (Treatments A and B), (2) within-litter between-animal (sex, 2 males and 2 females per litter), (3) within-animal (three repeated measurements at postnatal days 3, 6, and 9). How should I write the model? Thank you very much

      Comment


      • #4
        Originally posted by Flavia Chiarotti View Post
        . . . I heve seen the mixed procedure, but I could not understand from the manual how to formalize the model, with two levels of nesting (litter and animal within litter), and fixed effects (1) between-litter (Treatments A and B), (2) within-litter between-animal (sex, 2 males and 2 females per litter), (3) within-animal (three repeated measurements at postnatal days 3, 6, and 9). How should I write the model?
        See below. Start at the "Begin here" comment; the stuff above it is to create a toy dataset for illustration that resembles what you describe for yours.

        It shows syntax for both mixed and anova.
        Code:
        version 19
        
        clear *
        
        // seedem
        set seed 1104645385
        
        quietly set obs 12
        generate byte lid = _n
        generate double lid_u = rnormal()
        
        generate byte ab = mod(_n, 4)
        generate byte a = inlist(ab, 1, 3)
        generate byte b = inlist(ab, 2, 3)
        
        quietly expand 2
        bysort lid: generate byte sex = _n - 1
        quietly expand 2
        sort lid sex
        generate byte aid = _n
        generate double aid_u = rnormal()
        
        quietly expand 3
        bysort aid: generate byte tim = _n * 3
        
        generate double out = rnormal(lid_u + aid_u, 1)
        
        *
        * Begin here
        *
        mixed out i.a##i.b##i.sex##i.tim || lid: || aid: , ///
            reml dfmethod(satterthwaite) ///
            nolrtest nolog
        contrast a b a#b sex a#sex b#sex a#b#sex ///
            tim a#tim b#tim a#b#tim sex#tim a#sex#tim b#sex#tim a#b#sex#tim, small
        
        anova out a b a#b / lid|a#b sex a#sex b#sex a#b#sex / aid|a#b#sex ///
            tim a#tim b#tim a#b#tim sex#tim a#sex#tim b#sex#tim a#b#sex#tim, sequential
        
        exit
        Complete do-file and log file are attached if you're interested further.
        Attached Files

        Comment

        Working...
        X