Jeff DaCosta wrote:>
> I am really having trouble with getting the right syntax for my
> model. Here is a truncated version of my data:
>
> > data
> Ind Treatment Order Date PC1
> 1 PER14 SC 3rd 4-May-09 0.5704611
> 2 PER14 SH 1st 26-Apr-09 0.5329025
> 3 PER14 AC 2nd 29-Apr-09 2.1392279
> 4 PER25 SC 2nd 29-Apr-09 -0.2083382
> 5 PER25 SH 3rd 3-May-09 3.7818356
> 6 PER25 AC 1st 26-Apr-09 -1.9689733
> 7 PER30 SC 1st 24-Apr-09 -0.1255970
> 8 PER30 SH 2nd 27-Apr-09 2.1474393
> 9 PER30 AC 3rd 30-Apr-09 -1.8683396
>
> > str(data)
> 'data.frame': 9 obs. of 5 variables:
> $ Ind : Factor w/ 3 levels "PER14","PER25",..: 1
1 1 2 2 2 3 3 3
> $ Treatment: Factor w/ 3 levels
"AC","SC","SH": 2 3 1 2 3 1 2 3 1
> $ Order : Factor w/ 3 levels
"1st","2nd","3rd": 3 1 2 2 3 1 1 2 3
> $ Date : Factor w/ 7 levels
"24-Apr-09","26-Apr-09",..: 7 2 4 4
> 5 2 1 3 6
> $ PC1 : num 0.57 0.533 2.139 -0.208 3.782 ...
>
> > factor(Order, ordered=TRUE)
> [1] 3rd 1st 2nd 2nd 3rd 1st 1st 2nd 3rd
> Levels: 1st < 2nd < 3rd
>
> > factor(Date,ordered=TRUE)
> [1] 4-May-09 26-Apr-09 29-Apr-09 29-Apr-09 3-May-09 26-Apr-09 24-
> Apr-09 27-Apr-09 30-Apr-09
> Levels: 24-Apr-09 < 26-Apr-09 < 27-Apr-09 < 29-Apr-09 <
3-May-09 < 30-
> Apr-09 < 4-May-09
>
> "Ind" are different individuals in the study, each of which
received
> three "Treatment"s (SC, SH, and AC). The "Order"
(ordered=TRUE) in
> which each individual received a treatment was systematically
> shuffled in the study, and the "Date" (ordered=TRUE) is simply
when
> each treatment was completed. The response variable are scores from
> a principal components analysis ("PC1").
>
> So I want to run a model where "PC1" is the response variable and
> "Ind" is nested within "Treatment", and I also want to
include
> "Order" and "Date" as random factors.
>
> I have been struggling to describe the model with aov, lm, lme, and
> lmer, and don't think I'm getting the syntax right. Suggestions?
>
>
I suggest you forward to the r-sig-mixed-models list, where the
question is less likely to get lost in the noise.
A few other thoughts:
* "Order" might as well be treated as fixed, you probably won't be
able to
get a reliable estimate of its associated variance.
* I'm not sure that you'll be able to make very much use of the ordering
of
the factors (unless you want to be extreme and treat them as continuous
covariates, i.e. fit a linear trend) in the aov/lme/lmer world.
* I would think that
lmer(PC1 ~ Treatment*Order+(1|Ind)+(1|Date),data=data)
would be a good start.
Have you read Pinheiro and Bates 2000?
Ben Bolker
--
View this message in context:
http://www.nabble.com/nested-model-with-random-factors-tp24398026p24401470.html
Sent from the R help mailing list archive at Nabble.com.