Java Mailing List Archive

http://www.r-help.com/

Home » Home (12/2007) » R Help for Statistical Computing »

[R] problems with nls function

Yimeng Lu

2005-07-14


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@(protected)
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
©2008 r-help.com - Jax Systems, LLC, U.S.A.