# Re: [R] problems with nls function

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

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

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))))

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