[Rd] predict.gnls seems to break when 'newdata' specified (PR#10364)

From: <jenny_at_stat.ubc.ca>
Date: Mon, 22 Oct 2007 20:00:15 +0200 (CEST)


Full_Name: Jennifer Bryan
Version: 2.5.1
OS: Mac OS 10.4.10
Submission from: (NULL) (142.103.104.81)

The predict method for gnls seems to break when I provide 'newdata'. It seems to be the code that checks that the factors in newdata have the same contrasts as the data provided for the original fit. I illustrate below with an example from Pinheiro and Bates. I can't even use predict on the original data.frame when I provide the original data as newdata.

## copied verbatim from Pinheiro & Bates 8.3.3
fm1Dial.gnls <-
  gnls(rate ~ SSasympOff(pressure, Asym, lrc, c0),

       data = Dialyzer, params = list(Asym + lrc ~ QB, c0 ~ 1),
       start = c(53.6, 8.6, 0.51, -0.26, 0.225))

## differs from P & B only due to different default contrasts
Dialyzer$QBcontr <- ifelse(Dialyzer$QB == 200, 0, 1) fm1Dial.nls <-
  nls(rate ~ SSasympOff(pressure, Asym.Int + Asym.QB * QBcontr,
                        lrc.Int + lrc.QB * QBcontr, c0), data =
      Dialyzer, start = c(Asym.Int = 53.6, Asym.QB = 17,
                  lrc.Int = 0.51, lrc.QB = -0.5, c0 = 0.225))

## I get the same results from the above fits, they differ from those
## in the book due to different contrasts
predict(fm1Dial.gnls)                     # works
predict(fm1Dial.gnls, newdata = Dialyzer) # fails, factor levels complaint predict(fm1Dial.nls, newdata = Dialyzer) # works

R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Mon 22 Oct 2007 - 19:00:15 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 25 Oct 2007 - 11:37:11 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.