[R] linear mixed model question
Jason Morgan
jwm-r-help at skepsi.net
Sun Sep 6 19:48:01 CEST 2009
Hello Wen:
On 2009.09.06 10:49:03, Wen Huang wrote:
> Hello,
>
> I wanted to fit a linear mixed model to a data that is similar in
> terms of design to the 'Machines' data in 'nlme' package except that
> each worker (with triplicates) only operates one machine. I created a
> subset of observations from 'Machines' data such that it looks the
> same as the data I wanted to fit the model with (see code below).
>
> I fitted a model in which 'Machine' was a fixed effect and 'Worker'
> was random (intercept), which ran perfectly. Then I decided to
> complicate the model a little bit by fitting 'Worker' within
> 'Machine', which was saying variation among workers was nested within
> each machine. The model could be fitted by 'lme', but when I tried to
> get
> confidence intervals by 'intervals(fm2)' it gave me an error:
>
> Error in intervals.lme(fm2) :
> Cannot get confidence intervals on var-cov components: Non-positive
> definite approximate variance-covariance
>
> I am wondering if this is because it is impossible to fit a model like
> 'fm2' or there is some other reasons?
The problem doesn't seem to be the model specification but is most likely the
result of estimating a more complicated model with very little data. Using
the complete Machines dataset with the same model specification seems to work
fine:
# ----------------------------------------------------------------------------- #
> fm3 <- lme(score ~ Machine, random = ~ Machine - 1 | Worker, data = Machines)
> intervals(fm3)
Approximate 95% confidence intervals
Fixed effects:
lower est. upper
(Intercept) 48.972459 52.355556 55.73865
MachineB 3.093747 7.966667 12.83959
MachineC 10.816607 13.916667 17.01673
attr(,"label")
[1] "Fixed effects:"
Random Effects:
Level: Worker
lower est. upper
sd(MachineA) 2.1702468 4.0792807 7.6675752
sd(MachineB) 4.6301082 8.6252908 16.0677975
sd(MachineC) 2.3387870 4.3894795 8.2382579
cor(MachineA,MachineB) 0.1992744 0.8027499 0.9647702
cor(MachineA,MachineC) -0.1702480 0.6225047 0.9260744
cor(MachineB,MachineC) 0.1235115 0.7708309 0.9579666
Within-group standard error:
lower est. upper
0.7629124 0.9615766 1.2119736
# ----------------------------------------------------------------------------- #
With the restricted dataset, there are only 18 observations in 6 groups. This is
probably too little data for the (restricted) maximum likelihood technique used
by lme().
Hope that helps,
~Jason
--
Jason W. Morgan
Graduate Student
Department of Political Science
*The Ohio State University*
154 North Oval Mall
Columbus, Ohio 43210
More information about the R-help
mailing list