You really need to do some studying on mixed effects models.  Some resources 
are at: http://lme4.r-forge.r-project.org/

Your formula below is wrong, you fit only the intercept as a fixed effect and 
you are fitting a random slope on animal by day for the random effect, which 
does not make much sense, you want animal as the random piece, so it goes to 
the right of the '|'.  You also need to decide whether to fit only random 
intercepts (same slope/differences in each animal, just at a different 
intercept) or include the possibility of random slopes (each animal has 
different slopes, fixed effect is an average).

Your formula should probably be something more like: Count ~ Day + (1|Animal)
Or: Count ~ Day + (Day|Animal)

Further questions would probably be best on mixed effects SIG.

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

From: Bart Joosen [mailto:bartjoo...@hotmail.com]
Sent: Monday, June 07, 2010 11:37 PM
To: Greg Snow; r-help
Subject: RE: [R] Help with seting up comparison

Greg,


the animals are a sample of a larger population, as you guessed.

I used lmer to estimate the effects:


> lmer(Count~Animal | Day, dat)
Linear mixed model fit by REML
Formula: Count ~ Animal | Day
Data: dat
AIC BIC logLik deviance REMLdev
1554 1574 -772 1542 1544
Random effects:
Groups Name Variance Std.Dev. Corr
Day (Intercept) 1.7707e-02 0.1330678
Animal 4.0287e-05 0.0063472 1.000
Residual 2.0917e+00 1.4462790
Number of obs: 430, groups: Day, 4

Fixed effects:
Estimate Std. Error t value
(Intercept) 4.2423 0.1257 33.76


But how does this help me to state that there is no effect within an animal?
anova doesn't seems to work (gives an empty table)
I'm sorry, but I have no experience with lme models, only lm.


Thanks for your time


Bart



> From: greg.s...@imail.org
> To: bartjoo...@hotmail.com; r-help@r-project.org
> Date: Mon, 7 Jun 2010 14:54:47 -0600
> Subject: RE: [R] Help with seting up comparison
>
> 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.s...@imail.org
> 801.408.8111
>
>
> > -----Original Message-----
> > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
> > project.org] On Behalf Of Bart Joosen
> > Sent: Monday, June 07, 2010 9:14 AM
> > To: r-help@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@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.
________________________________
SMS "HOTMAIL" naar 3010 en ontvang gratis de juiste instellingen voor Hotmail 
op je mobiele 
telefoon.<http://www.microsoft.com/netherlands/windowslive/Views/productdetail.aspx?product=HotmailTelefoon>

        [[alternative HTML version deleted]]

______________________________________________
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.

Reply via email to