Re: [R] problems with nls function

From: Yimeng Lu <yl2058_at_columbia.edu>
Date: Fri 15 Jul 2005 - 13:31:10 EST


Sorry that I specified the x as
x=c(0, 0.4, 0.7, 1, 1.4, 1.6, 1.8, 2:10)

The error message is the same.

Thanks.

Hanna

  Hello,

  I was trying to fit a generalized logistic curve and my code for testing   if the function "nls" is working is like this
#######
#define the generalized logistic curve function
  glogit=function(a, b, c, m, t, x)

  {

  tmp = 1/(1 + t * exp(-b * (x - m)))^(1/t)

  model.func = a + tmp * c

#define the gradient vector

  Z = cbind(1, c*(x-m)*tmp^(t+1)*exp(-b*(x-m)), tmp, -c*b*exp(-b*(x-m)) *temp^(t+1), -c*tmp*(1/t)* (log(tmp) + tmp^(-t) * exp(-b(x-m))))

  attr(model.func,"gradient")=Z

  model.func

  }

  a= 0

  b=3

  c=6

  m=2

  t=0.75

  x=c(1:10)

  y=a + c/(1 + t * exp(-b * (x - m)))^(1/t) + rnorm(16, sd=0.01)

  plot(data.frame(x=x, y=y), type = "p", col = "red")

  nls(y ~ glogit(a, b, c, m, t, x), data=data.frame(y=y,x=x), start=list(a=1, b=2, c=3, m=1, t=0, x), trace=T)

#####End.

  When I ran this code, I got the error "Error in assign(i, temp, envir = env) : attempt to use zero-length variable name". What does this error mean? How should I fix it?

  Many thanks.

  Hanna Lu

  Dept. of Biostatistics

  Columbia University

        [[alternative HTML version deleted]]



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Fri Jul 15 13:36:44 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:33:43 EST