All right, humble-pie time.

Yesterday, I posted a query here:

https://github.com/lme4/lme4/issues/34

which Ben answered. I incorrectly said it didn't work, but Ben's solution
did, pointing out that I shouldn't use -attach()-. I shan't in future, and
it just required some proper thought on my part, which I post here at Ben's
request:

> library(lme4)
>
dd=transform(Dyestuff,lagY1=c(NA,head(Yield,-1)),lagY2=c(rep(NA,2),head(Yield,-2)),lagY3=c(rep(NA,3),head(Yield,-3)))
> lagY1=c(NA,Yield[1:(N-1)])
> lagY2=c(rep(NA,2),Yield[1:(N-2)])
> lagY3=c(rep(NA,3),Yield[1:(N-3)])
> (fit=lmer(Yield~1+lagY1+lagY2+lagY3+(1|Batch),Dyestuff,REML=T))
Linear mixed model fit by REML
Formula: Yield ~ 1 + lagY1 + lagY2 + lagY3 + (1 | Batch)
   Data: Dyestuff
   AIC BIC logLik deviance REMLdev
 299.2 307 -143.6    289.4   287.2
Random effects:
 Groups   Name        Variance Std.Dev.
 Batch    (Intercept) 2337.0   48.343
 Residual             2098.2   45.806
Number of obs: 27, groups: Batch, 6

Fixed effects:
             Estimate Std. Error t value
(Intercept) 1853.2758   407.5259   4.548
lagY1         -0.1354     0.1679  -0.807
lagY2          0.1109     0.1570   0.706
lagY3         -0.1833     0.1547  -1.185

Correlation of Fixed Effects:
      (Intr) lagY1  lagY2
lagY1 -0.607
lagY2 -0.485 -0.089
lagY3 -0.567  0.050 -0.079

The lags fail to reach significance in my own data, but that's by the by;
at least they fit.

Many thanks for your selfless help, Ben. It is most appreciated.

-- 
Clive Nicholas

"My colleagues in the social sciences talk a great deal about methodology.
I prefer to call it style." -- Freeman J. Dyson

	[[alternative HTML version deleted]]

