[Rd] bugfix for nls with port algorithm (PR#13540)

From: <Manuel.A.Morales_at_williams.edu>
Date: Thu, 19 Feb 2009 20:55:13 +0100 (CET)

Full_Name: Manuel A. Morales
Version: 2.8.1
OS: Linux
Submission from: (NULL) (

When fitting a model in nls using the algorithm port with constraints and the shorthand parameter[factor] in the model, I get the following error message:

"Error in nls_port_fit(m, start, lower, upper, control, trace) :   (list) object cannot be coerced to type 'double' In addition: Warning message:
In start < low :
  longer object length is not a multiple of shorter object length"

This error can be fixed by changing line 423 in nls.R from:

if(any(start < low || start > upp)) {


if(any(unlist(start) < low || unlist(start) > upp)) {

The following code will generate the error: x = runif(200)
b0 = c(rep(0,100),runif(100))
b1 = 1
fac <- as.factor(rep(c(0,1), each=100))
y = b0+b1*x+rnorm(200,sd=0.05)
nls(y~b0[fac]+b1*x, start=list(b0=c(1,1),b1=1), algorithm="port",



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Thu 19 Feb 2009 - 18:58:09 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 19 Feb 2009 - 21:30:28 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.

list of date sections of archive