Dear R-dev,

I have been having some problems with regards to names in the parameter
vector being stripped when passed to the objective function when using
nls(). I was relieved to find that it wasn't me, and that this behaviour has
previously been reported in optim() also. See eg
The solution at that time was to make a change so that vector passed into
the objective function was named (eg see following two discussions).

The problem that I am having is virtually identical, but is occuring with
nls() instead of optim(). To illustrate the problem, I have put together the
following example code (see bottom). Basically, it is doing a linear least
squares by hand, but it also displays the names associated on the parameters
vector - if you run it, you will see that the names are there for the first
few function evaluations, but after the first "step", the names are dropped.

I was wondering if I could please ask for a similar fix as that applied to
optim() to be carried across to nls() also?

Many thanks,


#Setup environment
counter <- 1

#Objective function for nls
fitting.fn <-function(x,params) {
  #The model - so that it works
  y <- params[1] + x*params[2]
  #Referring to the parameters this way stops working after the first "step"
#  y <- params["a"] + x*params["b"]

  #Display information about function eval and parameter names
  cat(paste("Evaluation # :",counter,"\t Names :"))
  counter <<- counter +1

#Synthetic data
data.x <- 1:50
data.y <- pi*data.x + rnorm(50,sd=20)

#Fit objective function
ips <-  c(a=0,b=0)

        [[alternative HTML version deleted]]

______________________________________________ mailing list

Reply via email to