[R] nlme, predict.nlme, levels not allowed
Patrick Giraudoux
patrick.giraudoux at univ-fcomte.fr
Sat Nov 5 18:03:05 CET 2005
Dear listers,
I am trying to fit a nlme model with "age" and "pds" as reals, and
"zone" a factor with two levels "Annaba" and "Boumalek" . The "best"
model found is the following:
> modm3
Nonlinear mixed-effects model fit by maximum likelihood
Model: pds ~ Asym/(1 + exp((xmid - age)/scal))
Data: croispulm
Log-likelihood: -91.86667
Fixed: list(Asym ~ zone, xmid ~ zone, scal ~ 1)
Asym.(Intercept) Asym.zoneBoumalek xmid.(Intercept)
xmid.zoneBoumalek scal
9.99551079 0.39423966 4.97981027
0.06969807 2.23116661
Random effects:
Formula: list(Asym ~ 1, xmid ~ 1)
Level: nichoir
Structure: General positive-definite, Log-Cholesky parametrization
StdDev Corr
Asym.(Intercept) 1.796565e-06 As.(I)
xmid.(Intercept) 1.219400e-04 0
Residual 6.163282e-01
Correlation Structure: Continuous AR(1)
Formula: ~age | nichoir
Parameter estimate(s):
Phi
0.3395242
Number of Observations: 102
Number of Groups: 17
Everything normal so far.
Things come to be strange when I try to compute predicted values:
> pred<-predict(modm3,newdata=mydata,type="response")
Error in predict.nlme(modm3, newdata = mydata, type = "response") :
Levels Annaba,Boumalek not allowed for zone
I have checked and re-checked that zone in the newdata is well a factor
with the "good" levels, and I can hardly understand why these two levels
used when fitting the model are now rejected when used for computing
predicted values.
Any hint welcome,
Best regards,
Patrick
More information about the R-help
mailing list