Hi:

One way out is to recode the values of sampling to reflect that they are
actually nested within specific levels of block * BA * CI combinations. With
your initial coding, you have to include the block * factor combination at
which the sampling is to take place.

I did this to recode the sampling variable:

os <- rep(seq(0, 25, by = 5), each = 10)

Using md as the name of the input data frame,

md$sampling <- md$sampling + os

so we get
> head(md)
  Block BA CI sampling ResponseVariable
1     a  B  C        1              3.4
2     a  B  C        1              2.5
3     a  B  C        2              7.8
4     a  B  C        2              6.5
5     a  A  C        3              3.4
6     a  A  C        3              1.2
> tail(md)
   Block BA CI sampling ResponseVariable
55     c  A  I       28              2.6
56     c  A  I       28              1.7
57     c  A  I       29              2.8
58     c  A  I       29              6.7
59     c  A  I       30              5.6
60     c  A  I       30              7.8

The recoded sampling values are now implicitly nested within factor
combination * block sets, so the call simplifies to

library(lme4)
m1 <- lmer(ResponseVariable ~ BA * CI + (1 | Block) + (1 | sampling), data =
md)
> m1
Linear mixed model fit by REML
Formula: ResponseVariable ~ BA * CI + (1 | Block) + (1 | sampling)
   Data: md
   AIC   BIC logLik deviance REMLdev
 286.3 301.0 -136.1    278.7   272.3
Random effects:
 Groups   Name        Variance Std.Dev.
 sampling (Intercept) 3.66065  1.91328
 Block    (Intercept) 0.18866  0.43435
 Residual             3.73767  1.93330
Number of obs: 60, groups: sampling, 30; Block, 3

Fixed effects:
            Estimate Std. Error t value
(Intercept)   4.6389     0.8229   5.637
BAB           0.1278     1.2393   0.103
CII          -0.6278     1.1085  -0.566
BAB:CII       1.2861     1.7527   0.734

Correlation of Fixed Effects:
        (Intr) BAB    CII
BAB     -0.602
CII     -0.674  0.447
BAB:CII  0.426 -0.707 -0.632

HTH,
Dennis

2011/3/7 Aitor Larrañaga <aitor.larranagaa@ehu.es>

> Dear list members,
>
> I am trying to model in R an experiment with the BACI structure, that is,
> consisting in a Before-After factor and a Control-Impacted one, both fixed.
> I had the same sampling structure in four locations, what makes location a
> random blocking factor. That would be easy for me if I had not also some
> samplings Before (2 samplings) and After (3 samplings) the affection we
> generated in our systems.
>
> In short, I have a random blocking factor, two fixed factors (BA and CI)
> and a random sampling factor nested within BA (BA/sampling). The number of
> samples within each cell is ten and I have not empty cells. The sources of
> variation I am interested in the model are:
>
> -BA
> -CI
> -BA*CI
> -BA/sampling
> -CI*(BA/sampling)
>
> I have tried many different types of syntaxes and none gives me a valid
> result. The packages I have used are nlme and lme4, with some preference to
> the first as p values are obtained more easily. One of the syntaxes I have
> used:
>
> model<-lme(Response~BA*CI+BA/Sampling+CI*BA/Sampling,random=~1|Block),
>
> gives the following error:
>
> Error in MEEM(object, conLin, control$niterEM) :
>  Singularity in backsolve at level 0, block 1
>
> Below I send an example of a dataset similar to what I am using (with just
> two cases per cell and three blocks for brevity).
>
> Block   BA              CI              sampling        ResponseVariable
> a               B               C               1                       3.4
> a               B               C               1                       2.5
> a               B               C               2                       7.8
> a               B               C               2                       6.5
> a               A               C               3                       3.4
> a               A               C               3                       1.2
> a               A               C               4                       0.9
> a               A               C               4                       2.3
> a               A               C               5                       2.2
> a               A               C               5                       5.6
> a               B               I               1                       8.9
> a               B               I               1                       9.0
> a               B               I               2                       1.4
> a               B               I               2                       1.4
> a               A               I               3                       2.7
> a               A               I               3                       4.4
> a               A               I               4                       4.0
> a               A               I               4                       3.7
> a               A               I               5                       2.2
> a               A               I               5                       1.1
> b               B               C               1                       7.0
> b               B               C               1                       6.9
> b               B               C               2                       5.6
> b               B               C               2                       3.4
> b               A               C               3                       2.3
> b               A               C               3                       1.1
> b               A               C               4                       1.8
> b               A               C               4                       9.6
> b               A               C               5                       5.4
> b               A               C               5                       6.6
> b               B               I               1                       1.0
> b               B               I               1                       7.7
> b               B               I               2                       5.9
> b               B               I               2                       3.3
> b               A               I               3                       3.2
> b               A               I               3                       2.1
> b               A               I               4                       0.9
> b               A               I               4                       4.3
> b               A               I               5                       7.7
> b               A               I               5                       8.7
> c               B               C               1                       6.5
> c               B               C               1                       3.8
> c               B               C               2                       3.4
> c               B               C               2                       0.4
> c               A               C               3                       6.8
> c               A               C               3                       4.4
> c               A               C               4                       9.6
> c               A               C               4                       6.5
> c               A               C               5                       6.1
> c               A               C               5                       7.7
> c               B               I               1                       9.9
> c               B               I               1                       7.6
> c               B               I               2                       5.6
> c               B               I               2                       3.4
> c               A               I               3                       2.6
> c               A               I               3                       1.7
> c               A               I               4                       2.8
> c               A               I               4                       6.7
> c               A               I               5                       5.6
> c               A               I               5                       7.8
>
> I would be eternally grateful to the list if someone can lead me to the
> answer of the matter.
>
> All the best,
>
> Aitor Larrañaga
> _______________________________________________
> R-sig-mixed-models@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>

	[[alternative HTML version deleted]]


