[R] Dúvida função Anova pacote car - Medidas repetidas
Rui Barradas
ruipbarradas at sapo.pt
Sat Oct 6 13:32:01 CEST 2012
Sorry,
Phone, daughter, forgot to sign.
Rui Barradas
Em 06-10-2012 12:28, Rui Barradas escreveu:
> Hello,
>
> Yes, your Spanish is close enough to Portuguese for you to understand it.
> I thought it was homework and didn't read untill the end. Apologies to
> Diego, and thanks to John.
>
> Rui Barradas
> Em 05-10-2012 22:48, John Fox escreveu:
>> Dear Diego,
>>
>> This is close enough to Spanish for me to understand it (I think).
>>
>> Using Anova() in the car package for repeated-measures designs
>> requires a
>> multivariate linear model for all of the responses, which in turn
>> requires
>> that the data set be in "wide" format, with each response as a
>> variable. In
>> your case, there are two crossed within-subjects factors and no
>> between-subjects factors. If this understanding is correct (but see
>> below),
>> then you could proceed as follows, where the crucial step is
>> reshaping the
>> data from "long" to "wide":
>>
>> ------------- snip --------------
>>
>> Pa2$type.day <- with(Pa2, paste(Type, Day, sep="."))
>> (Wide <- reshape(Pa2, direction="wide", v.names="logbiovolume",
>> idvar="Replicate", timevar="type.day", drop=c("Type", "Day")))
>>
>> day <- ordered(rep(c(0, 2, 4), each=2))
>> type <- factor(rep(c("c", "t"), 3))
>> (idata <- data.frame(day, type))
>>
>> mod <- lm(cbind(logbiovolume.c.0, logbiovolume.t.0, logbiovolume.c.2,
>> logbiovolume.t.2, logbiovolume.c.4, logbiovolume.t.4) ~ 1, data=Wide)
>>
>> Anova(mod, idata=idata, idesign=~day*type)
>>
>> ------------- snip --------------
>>
>> This serves to analyze the data that you showed; you'll have to adapt
>> it for
>> the full data set.
>>
>> I'm assuming that the "replicates" are independent units, and that the
>> design is therefore entirely within replicate. If that's wrong, then the
>> analysis I've suggested is also incorrect.
>>
>> I hope this helps,
>> John
>>
>> -----------------------------------------------
>> John Fox
>> Senator McMaster Professor of Social Statistics
>> Department of Sociology
>> McMaster University
>> Hamilton, Ontario, Canada
>>
>>
>>
>>
>>> -----Original Message-----
>>> From: r-help-bounces at r-project.org
>>> [mailto:r-help-bounces at r-project.org]
>>> On Behalf Of Diego Pujoni
>>> Sent: Friday, October 05, 2012 9:57 AM
>>> To: r-help at r-project.org
>>> Subject: [R] Dúvida função Anova pacote car - Medidas repetidas
>>>
>>> Ola pessoal, estou realizando uma ANOVA com medidas repetidas e estou
>>> utilizando a fungco "Anova" do pacote "car".
>>>
>>> Medi o biovolume de algas a cada dois dias durante 10 dias (no banco de
>>> dados abaixo ss coloquei ati o 40 dia). Tenho 2 tratamentos ("c","t") e
>>> o
>>> experimento foi realizado em triplicas ("A","B","C").
>>>
>>>> Pa2
>>> Day Type Replicate logbiovolume
>>> 1 0 c A 19.34
>>> 2 0 c B 18.27
>>> 3 0 c C 18.56
>>> 4 0 t A 18.41
>>> 5 0 t B 18.68
>>> 6 0 t C 18.86
>>> 7 2 c A 18.81
>>> 8 2 c B 18.84
>>> 9 2 c C 18.52
>>> 10 2 t A 18.29
>>> 11 2 t B 17.91
>>> 12 2 t C 17.67
>>> 13 4 c A 19.16
>>> 14 4 c B 18.85
>>> 15 4 c C 19.36
>>> 16 4 t A 19.05
>>> 17 4 t B 19.09
>>> 18 4 t C 18.26
>>> .
>>> .
>>> .
>>>
>>> Pa2.teste = within(Pa2,{group = factor(Type)
>>> time = factor(Day)
>>> id = factor(Replicate)})
>>> matrix =
>>> with(Pa2.teste,cbind(Pa2[,VAR][group=="c"],Pa2[,VAR][group=="t"]))
>>> matrix
>>> [,1] [,2]
>>> [1,] 19.34 18.41
>>> [2,] 18.27 18.68
>>> [3,] 18.56 18.86
>>> [4,] 18.81 18.29
>>> [5,] 18.84 17.91
>>> [6,] 18.52 17.67
>>> [7,] 19.16 19.05
>>> [8,] 18.85 19.09
>>> [9,] 19.36 18.26
>>> [10,] 19.63 18.96
>>> [11,] 19.94 18.06
>>> [12,] 19.54 18.37
>>> [13,] 19.98 17.96
>>> [14,] 20.99 17.93
>>> [15,] 20.45 17.74
>>> [16,] 21.12 17.60
>>> [17,] 21.66 17.33
>>> [18,] 21.51 18.12
>>> model <- lm(matrix ~ 1)
>>> design <- factor(c("c","t"))
>>>
>>> options(contrasts=c("contr.sum", "contr.poly"))
>>> aov <- Anova(model, idata=data.frame(design), idesign=~design,
>>> type="III")
>>> summary(aov, multivariate=F)
>>>
>>> Univariate Type III Repeated-Measures ANOVA Assuming Sphericity
>>>
>>> SS num Df Error SS den Df F Pr(>F)
>>> (Intercept) 12951.2 1 6.3312 17 34775.336 < 2.2e-16 ***
>>> design 19.1 1 17.3901 17 18.697 0.0004606 ***
>>> ---
>>> Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1
>>>
>>>
>>> O problema i que eu acho que esta fungco nco esta levando em
>>> consideragco
>>> os dias, nem as riplicas. Como fago para introduzir isto na analise.
>>> Vocjs
>>> conhecem alguma fungco correspondente nco paramitrica para este teste?
>>> Tipo
>>> um teste de Friedman com dois grupos (tratamento e riplica) e um bloco
>>> (tempo)?
>>>
>>> Muito Obrigado
>>>
>>> Diego PJ
>>>
>>> [[alternative HTML version deleted]]
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list