[R] using reshape to do ANOVA mixed models

Peter Dalgaard p.dalgaard at biostat.ku.dk
Fri Nov 27 21:26:11 CET 2009


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)              FAX: (+45) 35327907




More information about the R-help mailing list