Skip to content
Prev 354723 / 398500 Next

How to coerce a parameter in nls?

Hello, Gabor,

Thanks again for your suggestion. And now I am trying to improve the
code by adding a function to replace the express "Rm1 * ref.1 + Rm2 *
ref.2 + Rm3 * ref.3 + Rm4 * ref.4 + Rm5 * ref.5 + Rm6 * ref.6" because
I have some other dataset need to fitted to the same model but with
more groups (>20).

I tried to add the function as:

denfun<-function(i){
               for(i in 1:6){
                 Rm<-sum(Rm[i]*ref.i)
                 return(Rm)}
}

but I got another error when I incorporate this function into my regression:
data = dproot2,
                 start = c(Rm1=1.01, Rm2=1.01, Rm3=1.01, Rm4=6.65,
Rm5=1.01, Rm6=1, d50=20, c=-1),
                masked = "Rm6")

Error in deriv.default(parse(text = resexp), names(start)) :
  Function 'denfun' is not in the derivatives table

I think there must be something wrong with my function. I tried some
times but am not sure how to improve it because I am quite new to R.

Could anyone please give me some suggestion.

Thanks a lot!


Jianling


On 22 September 2015 at 00:43, Gabor Grothendieck
<ggrothendieck at gmail.com> wrote: