# [R] Help with seting up comparison

Greg Snow Greg.Snow at imail.org
Mon Jun 7 22:54:47 CEST 2010

```Are you interested in only those 35 animals (not every going to look at any other animals other than those 35, but you want to predict what will happen for those 35)? Or are the 35 animals a sample of a larger population of animals?

If the later (seems the most likely case) then you probably want to use a mixed effects model (nlme or lme4 packages) with animal as a random effect, then just look at the fixed effect of day.

Hope this helps,

--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org
801.408.8111

> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Bart Joosen
> Sent: Monday, June 07, 2010 9:14 AM
> To: r-help at r-project.org
> Subject: [R] Help with seting up comparison
>
>
> Hi,
>
> I tried on this, but couldn't figure it out:
> Suppose I have a dataframe as follows:
> dat <- data.frame(Day=rep(rep(c(1,2), each=4),2), Animal = rep(c(1,2),
> each=8), Count=c(rnorm(8, 100), rnorm(8,90)))
>
> 2 animals are being examined on 2 different days. Count is the result.
>
> Now I need to point out whether or not there is a difference between
> the
> days.
> I did this by an ANOVA test, while first converting the animal and day
> to a
> factor variable:
> dat\$Animal <- as.factor(dat\$Animal)
> dat\$Day <- as.factor(dat\$Day)
> mod <- lm(Count ~Animal * Day,dat)
> anova(mod)
>
> Now I have to check for difference within the animal, to see if there
> is a
> difference in count for each day. (In my real data, I have 35 animals,
> with
> 4 days, and 4 results).
> I thought about a Tukey HSD test, but this compares every day of every
> animal with every other day of every other animal. (TukeyHSD(aov(mod)))
>
> Any idea about which function (or model for lm) to use to only compare
> days
> within every animal?
>
> Best regards
>
> Bart
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Help-with-
> seting-up-comparison-tp2246106p2246106.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help