[R] Substitute initial guesses of parameters in a function
murdoch.duncan at gmail.com
Wed Dec 3 14:02:17 CET 2014
On 03/12/2014 7:37 AM, philippe massicotte wrote:
> Hi everyone, I have a formula like this:
> f <- as.formula(y ~ p0a * exp(-0.5 * ((x - p1a)/p2a)^2))
> I would like to "dynamically" provide starting values for p0a, p1a, p2a. Is there a way to do it?
Just give a named vector of starting values.
> #Params estimates
> p <- c(12, 10, 1)
Should be p <- c(p0a = 12, p1a = 10, p2a = 1)
> # This is where I have difficulties
> mystart <- substitute(...)
> nls(formula = f, start = mystart)
Now start = p will work. No need to mess with substitute. (And no need
to use as.formula on the very first line; that's already a formula.)
> [[alternative HTML version deleted]]
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help