[R] using reshape to do ANOVA mixed models

Orduek orduek at gmail.com
Sat Nov 28 14:32:05 CET 2009


Thank you.


On 28/11/2009, at 14:04, Peter Dalgaard <p.dalgaard at biostat.ku.dk>  
wrote:

> Or Duek wrote:
>> I'm sorry, I don't know how to copy it to the list.
>> as for the output and functions I've used:
>
> Use the Cc:! I am NOT answering list questions in private mails.
>
> -p
>
>> dm<-aov(value~(exposure*Treatment*Strain)+Error(subject/exposure) +  
>> (Strain*Treatment), mdata)
>> (* exposure=distance)
>> then I do : summary(dm)
>> Thank you very much for your patient.
>> On Sat, Nov 28, 2009 at 12:33 AM, Peter Dalgaard <p.dalgaard at biostat.ku.dk 
>>  <mailto:p.dalgaard at biostat.ku.dk>> wrote:
>>    Did you copy this to the list? Otherwise, please do. Again, please
>>    show the output and model spec.
>>    Or Duek wrote:
>>        I am sorry for my ignorance.
>>        I finally understood what I didi wrong - I used a numerical
>>        variable as the sibject variable, adding a factor subject
>>        variable fixed the issue.
>>        one the same analysis, how can I check for simple main effect?
>>        here is my data:
>>          subject Treatment Strain        distance   value
>>        1     sub1       DFP    C57 Distance_open_1  311.29
>>        2     sub2    Saline    C57 Distance_open_1  891.28
>>        3     sub3    Saline    C57 Distance_open_1 1162.02
>>        4     sub4       DFP    C57 Distance_open_1  366.04
>>        5     sub5    Saline    C57 Distance_open_1 1090.44
>>        6     sub6       DFP    C57 Distance_open_1  857.20
>>        7     sub7       DFP    C57 Distance_open_1  711.79
>>        8     sub8    Saline    C57 Distance_open_1  776.84
>>        9     sub9    Saline    C57 Distance_open_1  599.84
>>        10   sub10       DFP Balb/C Distance_open_1   97.19
>>        11   sub11    Saline Balb/C Distance_open_1 1000.22
>>        12   sub12       DFP Balb/C Distance_open_1   84.52
>>        13   sub13    Saline Balb/C Distance_open_1  476.70
>>        14   sub14       DFP Balb/C Distance_open_1  470.26
>>        15   sub15    Saline Balb/C Distance_open_1   31.39
>>        16   sub16       DFP Balb/C Distance_open_1   94.97
>>        17   sub17    Saline Balb/C Distance_open_1  477.18
>>        18   sub18       DFP Balb/C Distance_open_1  255.26
>>        19   sub19    Saline Balb/C Distance_open_1    0.00
>>        20   sub20       DFP Balb/C Distance_open_1  518.30
>>        21   sub21    Saline Balb/C Distance_open_1  126.23
>>        22   sub22       DFP Balb/C Distance_open_1  851.33
>>        23   sub23    Saline Balb/C Distance_open_1   99.57
>>        24   sub24       DFP Balb/C Distance_open_1  680.06
>>        25   sub25       DFP Balb/C Distance_open_1  777.27
>>        26   sub26    Saline Balb/C Distance_open_1  480.76
>>        27   sub27       DFP    C57 Distance_open_1 1253.18
>>        28   sub28       DFP    C57 Distance_open_1 1594.03
>>        29   sub29    Saline    C57 Distance_open_1  987.58
>>        30   sub30       DFP    C57 Distance_open_1  453.49
>>        31   sub31    Saline    C57 Distance_open_1  918.19
>>        32   sub32       DFP    C57 Distance_open_1  693.64
>>        33   sub33    Saline    C57 Distance_open_1  767.83
>>        34   sub34       DFP    C57 Distance_open_1   63.57
>>        35   sub35    Saline    C57 Distance_open_1  785.34
>>        36   sub36    Saline    C57 Distance_open_1 1243.88
>>        37    sub1       DFP    C57 Distance_open_2  122.24
>>        38    sub2    Saline    C57 Distance_open_2  759.94
>>        39    sub3    Saline    C57 Distance_open_2  937.23
>>        40    sub4       DFP    C57 Distance_open_2  669.66
>>        41    sub5    Saline    C57 Distance_open_2  515.78
>>        42    sub6       DFP    C57 Distance_open_2  333.22
>>        43    sub7       DFP    C57 Distance_open_2  403.76
>>        44    sub8    Saline    C57 Distance_open_2  393.75
>>        45    sub9    Saline    C57 Distance_open_2  428.75
>>        46   sub10       DFP Balb/C Distance_open_2    0.00
>>        47   sub11    Saline Balb/C Distance_open_2  520.48
>>        48   sub12       DFP Balb/C Distance_open_2    0.00
>>        49   sub13    Saline Balb/C Distance_open_2  444.85
>>        50   sub14       DFP Balb/C Distance_open_2   14.10
>>        51   sub15    Saline Balb/C Distance_open_2    6.49
>>        52   sub16       DFP Balb/C Distance_open_2    0.00
>>        53   sub17    Saline Balb/C Distance_open_2  242.39
>>        54   sub18       DFP Balb/C Distance_open_2  454.05
>>        55   sub19    Saline Balb/C Distance_open_2    0.00
>>        56   sub20       DFP Balb/C Distance_open_2  524.07
>>        57   sub21    Saline Balb/C Distance_open_2   24.33
>>        58   sub22       DFP Balb/C Distance_open_2  807.50
>>        59   sub23    Saline Balb/C Distance_open_2   59.99
>>        60   sub24       DFP Balb/C Distance_open_2  584.57
>>        61   sub25       DFP Balb/C Distance_open_2  868.57
>>        62   sub26    Saline Balb/C Distance_open_2  646.53
>>        63   sub27       DFP    C57 Distance_open_2 1144.82
>>        64   sub28       DFP    C57 Distance_open_2  869.61
>>        65   sub29    Saline    C57 Distance_open_2  626.32
>>        66   sub30       DFP    C57 Distance_open_2  203.48
>>        67   sub31    Saline    C57 Distance_open_2  957.98
>>        68   sub32       DFP    C57 Distance_open_2  382.35
>>        69   sub33    Saline    C57 Distance_open_2  522.27
>>        70   sub34       DFP    C57 Distance_open_2   16.61
>>        71   sub35    Saline    C57 Distance_open_2  555.44
>>        72   sub36    Saline    C57 Distance_open_2 1197.95
>>        thank you very much for your help.
>>        On Fri, Nov 27, 2009 at 10:26 PM, Peter Dalgaard
>>        <p.dalgaard at biostat.ku.dk <mailto:p.dalgaard at biostat.ku.dk>
>>        <mailto:p.dalgaard at biostat.ku.dk
>>        <mailto:p.dalgaard at biostat.ku.dk>>> wrote:
>>           Or Duek wrote:
>>               Hi,
>>               I just started with R and I found that there are many
>>        options to
>>               rearrange
>>               the data to do mixed models.
>>               I want to use the reshape function. I have 2 between  
>> subject
>>               variables and
>>               one within.
>>               I was able to change the data structure but still - the
>>        result
>>               of the aov
>>               functions are calculating everything as a within  
>> subject.
>>               the table looks like this:
>>               SerialNo    breed    treatment    distance_1    
>> distance_2
>>               1               c57       dfp             235                     3253
>>               etc.
>>               I changed it to look like this:
>>               SerialNo   breed   treatment    exposure   distance
>>               1              c57     dfp                
>> 1              235
>>               1              c57    dfp                 
>> 2              3253
>>               etc.
>>               Then I do:
>>                      dt<-aov(distance~(exposure*treatment*breed) 
>> +Error(SerialNo/exposure)
>>               +
>>               (treatment*breed), dataframe)
>>               what am I doing wrong?
>>           For a start, not showing us the output.... Also not  
>> showing us
>>           enough of the data and not convincing us that you are
>>        actually using
>>           the reshaped data frame.
>>           --      O__  ---- Peter Dalgaard             Øster
>>        Farimagsgade 5, Entr.B
>>            c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014  
>> Cph. K
>>            (*) \(*) -- University of Copenhagen   Denmark      Ph:
>>         (+45) 35327918
>>           ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk
>>        <mailto:p.dalgaard at biostat.ku.dk>
>>           <mailto:p.dalgaard at biostat.ku.dk
>>        <mailto:p.dalgaard at biostat.ku.dk>>)              FAX: (+45)  
>> 35327907
>>    --       O__  ---- Peter Dalgaard             Øster Farimagsgad 
>> e 5, Entr.B
>>     c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
>>     (*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45)  
>> 35327918
>>    ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk
>>    <mailto:p.dalgaard at biostat.ku.dk>) FAX: (+45) 35327907
>
>
> -- 
>   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
>  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
> (*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45)  
> 35327918
> ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)              FAX: (+45)  
> 35327907




More information about the R-help mailing list