[R] nls and start values evaluation
Petr PIKAL
petr.pikal at precheza.cz
Wed Feb 25 14:30:09 CET 2009
Dear all
I have troubles with correct evaluating/structure of nls input
x<-1:10
y<-1/(.5-x)+rnorm(10)/100
form <- structure(list(a = list(quote(y ~ 1/(a - x)), "list(a=mean(y))")),
.Names = "a")
This gives me an error due to not suitable default starting value
fit <- nls(form [[1]] [[1]], data.frame(x=x, y=y))
This works and gives me a result
fit <- nls(form [[1]] [[1]], data.frame(x=x, y=y), start=list(a=mean(y)))
How to organise list "form" and call to nls to enable to use other then
default starting values.
I thought about something like
fit <- nls(form [[1]] [[1]], data.frame(x=x, y=y), start=get(form [[1]]
[[2]]))
but this gives me an error so it is bad function. (BTW I tried eval,
assign, sustitute, evalq and maybe some other options but did not get it
right.
I know I can put starting values interactively but what if I want them
computed by some easy way which is specified by second part of a list,
like in above example.
If it matters
WXP, R2.9.0 devel.
Regards
Petr
More information about the R-help
mailing list