Petr PIKAL wrote:
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 you really want to orgnize it that way, why not simpler as in:

form <- list(y ~ 1/(a - x), a = mean(y))
fit <- nls(form[[1]], data.frame(x=x, y=y), start = form[2])


Uwe Ligges


If it matters
WXP,  R2.9.0 devel.

Regards
Petr

petr.pi...@precheza.cz

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to