Hi:
I did the following (note a fix to the assumed typo in t + 0.5 -> T + 0.5)
using the melt() function in package reshape2, the lattice graphics package
and package lme4. I named your input data df.
library(reshape) # or reshape2 if you have it
# Fix the typo:
df[4, 1] <- 'T+0.5'
# Redefine the factor to produce the correct number of levels:
df$traitement <- factor(df$traitement)
# Create a subject variable to distinguish profiles in time
df$subject <- as.numeric(row.names(df))
# reshape the data from wide format to long
dm <- melt(df, id = c('traitement', 'subject'))
# sort the reshaped data frame
dm <- dm[order(dm$traitement, dm$subject, dm$variable), ]
head(dm)
# Create a numeric time variable by stripping off the 't's
dm$time <- as.numeric(sub('^t','', dm$variable))
# Plot the individual profiles over time by treatment type
library(lattice)
xyplot(value ~ time | traitement, data = dm, groups = subject, type =
c('p',
'l'))
# The individual profiles are almost uniformly linearly increasing
# with a couple of obvious nonconforming points visible in the plots.
# There are mean differences among treatments,
# but also unbalanced replication in subjects. Treatment (SED + ER) has only
one subject.
# One way to fit a model:
library(lme4)
m1 <- lmer(value ~ traitement + (1 + time | subject), data = dm, reml = 0)
summary(m1)
This fits a mixed effects model with random subjects and time as a repeated
measures variable, using maximum likelihood to fit the model. This
particular specification treats time as numeric rather than factor because
the linear component is so strong, but it is possible to replace it with the
factor version instead (variable in data frame dm). The output of this model
fit shows a very small residual effect, a strong correlation between time
and subject (the sign seems wrong, though) and about the same amount of
variation between subjects as within subjects. This is a model you should
seriously consider, as it takes proper account of the randomness of subjects
and the nesting of time as a linear effect within subject. I would encourage
you to follow this direction, but there is much to learn if you are to use
the lme4 package.
I suspect, however, you're looking for something more along the lines of
Anova() in the car package, which uses the 'traditional' ANOVA approach
to
repeated measures models. If you go in this direction, be sure you
understand the underlying assumptions of the model.
For multiple comparisons, which I presume you'll want to investigate,
there's the TukeyHSD() function that you could use with Anova(), or for more
general methods, the multcomp package, which has a function glht() that can
be used with a mixed effects model per above or with an Anova() object. The
multcomp package has several useful vignettes and a recent book that
describes its essential features.
Refs:
Bretz, Hothorn and Westfall (2010). Multiple Comparisons in R. Chapman &
Hall.
Fox and Weisberg (2011). An R Companion to Applied Regression, 2nd ed. Sage
Publications. (Just out!)
HTH,
Dennis
On Tue, Dec 21, 2010 at 3:10 PM, soileil <soileil@msn.com> wrote:
>
> I currently work on a draft of an aquatic bioassessment. The conditions
> tested are the following: ER river water T dechlorinated water control 0.5
> +
> 0.5mg / L of malate T + 1 dechlorinated water control + 1g / L of malate T
> ED dechlorinated water control SED + ER + river water sediment SED ED +
> sediment + water dechlorinated. It is the result of AChE in muscle (fillet
> of fish). The production of acetylcholine is followed with a
> spectrophotometer every 15 seconds for two minutes. The results are
> presented in the following table:
>
>
> traitement t15 t30 t45 t60 t75 t90 t105 t120
> ER 0.100 0.110 0.123 0.135 0.147 0.159 0.171 0.182
> ER 0.112 0.134 0.153 0.174 0.192 0.208 0.226 0.251
> T+0.5 0.078 0.082 0.088 0.094 0.101 0.108 0.113 0.120
> t+0.5 0.053 0.100 0.109 0.120 0.127 0.136 0.145 0.154
> TED 0.107 0.126 0.141 0.161 0.172 0.184 0.200 0.213
> TED 0.117 0.135 0.153 0.169 0.183 0.201 0.218 0.229
> TED 0.124 0.145 0.163 0.187 0.208 0.227 0.244 0.259
> T+1 0.109 0.119 0.134 0.148 0.163 0.174 0.187 0.202
> T+1 0.118 0.134 0.153 0.170 0.184 0.197 0.214 0.228
> SED+ER 0.158 0.175 0.194 0.208 0.226 0.240 0.259 0.268
> SED+ED 0.119 0.140 0.157 0.174 0.192 0.208 0.225 0.240
> SED+ED 0.101 0.113 0.180 0.140 0.154 0.166 0.179 0.190
> SED+ED 0.129 0.135 0.140 0.146 0.153 0.159 0.165 0.172
>
>
> The statistical test is considered a repeated measures anova but I do not
> know how to do it in R. I watched the forums and I downloaded the R package
> 'nlme' by which I should be able to use the function 'lm'.
But the problem
> is that I can not encode this function. Could you help me?
> --
> View this message in context:
>
http://r.789695.n4.nabble.com/please-Help-me-on-a-repeated-measures-anova-tp3159868p3159868.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help@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.
>
[[alternative HTML version deleted]]