Re: [R] nlme function in S+ and R

From: Bert Gunter <gunter.berton_at_gene.com>
Date: Thu, 15 May 2008 14:24:36 -0700

Derrick:

  1. There are lots of people "out here" with such experience -- including the author of the software!
  2. nlme fitting involves iterative procedures whose final value (if indeed, convergence to a final value occurs -- it certainly need not) depends on a) the initial value you start from; (b) various control parameters (tolerances, step sizes, direction), most of which are user-specifiable with certain defaults; (c) the details of the iterative algorithms; (d)the exact data: overspecified models can lead to great sensitivity to the other aspects; and (e) the details of the numeric software in which the algorithms are implemented.

afaics, you have only guaranteed that a) and d) are the same between S+ and R (versions??? -- as requested by the posting guide!). However, in my experience, it is very easy to overspecify nonlinear models (since this depends in very complex ways on the exact data that you have), yielding sensitivity to all of b,c, and e. So the differences that you see are not surprising.

 -----Original Message-----
From: r-help-bounces_at_r-project.org [mailto:r-help-bounces_at_r-project.org] On Behalf Of d.lee_at_stat.ubc.ca
Sent: Thursday, May 15, 2008 12:19 PM
To: r-help_at_r-project.org
Subject: [R] nlme function in S+ and R

Greetings and Salutations,

I was curious if anyone out there has had much experience with the nlme function
in both S+ and R. Right now I am working on an HIV dataset and trying to fit a
NLME model to the data, and the coefficients I get in S+ differ slightly from
the coefficients in R:

R model : 12.44 0.84 39.07 10.70 4.48 7.48 0.60 1.85 0.18 S model : 12.45 0.59 36.65 1.07 5.46 7.59 0.35 1.92 0.20

Since there is a random component, I expect there to be some deviations from one
another, but as you can see the coefficients for the 4th variable are just too
different from one another and hence my concern. The S+ code I am using is:

fit4 <- try(nlme(lgcopy ~ logexp2(p1,b1,p2,b2,day),

                 fixed = list(p1 ~tnf, b1 ~tnf+cd4coun, p2~tnf,b2~basech50),
                 random = list(p1 ~ .,b1 ~.,p2~.,b2~.),
                 cluster = ~ patid,
                 data = completedata,
                 start = list(fixed=start0)

)
)

and, I believe, I made the appropriate adjustments for R:

fit4 <- try(nlme(lgcopy ~ logexp2(p1,b1,p2,b2,day),

                 fixed = list(p1 ~tnf, b1 ~tnf+cd4coun, p2~tnf,b2~basech50),
                 random = list(p1+b1+p2+b2~1),
                 groups = ~ patid,
                 data = completedata,
                 start = list(fixed=start0)

)
)

If anyone could lend some insight to this difference, it would be very much appreciated. Cheers.

Sincerely

 Derrick Lee, MSc Candidate
 Department of Statistics
 The University of British Columbia
 LSK-314A | 604 - 822 - 1299 x532
 d.lee at stat dot ubc dot ca | dgylee at mun dot ca  www.stat.ubc.ca/~d.lee/ | www.math.mun.ca/~derrick0/



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.

R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Thu 15 May 2008 - 21:28:00 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 15 May 2008 - 21:30:46 GMT.

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

list of date sections of archive