[R] nls does not accept start values
Petr PIKAL
petr.pikal at precheza.cz
Mon Mar 2 08:37:24 CET 2009
Hi to all
OK as I did not get any response and I really need some insight I try
again with different subject line
I have troubles with correct evaluating/structure of nls input
Here is an example
# data
x <-1:10
y <-1/(.5-x)+rnorm(10)/100
# formula list
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 not correct syntax. (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
petr.pikal at precheza.cz
More information about the R-help
mailing list