[R] passing local parameters to nls?

ivo welch ivowel at gmail.com
Wed Jun 9 15:39:18 CEST 2010


dear R wizards:  environment-related programming question:

myformula = y ~ a*x^2+b*x+c
d= data.frame( x=rnorm(20), y=rnorm(20) )

cat("\nunconstrained works: \n");
nls( myformula, data=d, start=list(a=1, b=1, c=1), trace= TRUE)

cat("\nconstrained works: \n");
b=1; nls( myformula, data=d, start=list(a=1, c=1), trace= TRUE); rm(b)

cat("\nbut how do I pass a local parameter into my formula? \n");
f = function(c) nls( myformula, data=d, start=list(a=1, b=1), trace= TRUE)

f(c=1);

advice, as always, appreciated.  /iaw

----
Ivo Welch (ivo.welch at brown.edu, ivo.welch at gmail.com)



More information about the R-help mailing list