hi: could someone please point me to a function that allows me to solve general non-linear functions? > irr.in <- function(r, c1, c2, c3 ) { return(c1+c2/(1+r) + c3/(1+r)^2); } > solve.nonlinear( irr.in, -100, 60, 70 ); 0.189 If someone has written an irr function, this would be helpful, too---though not difficult to write, either. thanks for any pointers. Regards, /iaw --- ivo welch
See ?uniroot:> uniroot(irr.in, c(-1, 1), c1=-100, c2=60, c3=70)$root [1] 0.1888196 $f.root [1] -1.514979e-05 $iter [1] 8 $estim.prec [1] 6.103516e-05 Warning message: NA/Inf replaced by maximum positive value Andy> From: ivo_welch-rstat8783 at mailblocks.com > > hi: could someone please point me to a function that allows me to > solve general non-linear functions? > > > irr.in <- function(r, c1, c2, c3 ) { return(c1+c2/(1+r) + > c3/(1+r)^2); } > > solve.nonlinear( irr.in, -100, 60, 70 ); > 0.189 > > If someone has written an irr function, this would be helpful, > too---though not difficult to write, either. thanks for any pointers. > > Regards, > > /iaw > --- > ivo welch > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > >
From: <ivo_welch-rstat8783 at mailblocks.com> Date: Tue 02 Nov 2004 - 00:55:31 EST> hi: could someone please point me to a function that allows me to > solve general non-linear functions? > > > irr.in <- function(r, c1, c2, c3 ) { return(c1+c2/(1+r) + > c3/(1+r)^2); } > > solve.nonlinear( irr.in, -100, 60, 70 ); > 0.189 > > If someone has written an irr function, this would be helpful, > too---though not difficult to write, either. thanks for any > pointers. > > Regards, > > /iawoptim, nlm - for general optimization; nls, nls.lm from `minpack.lm' package - for solving the least-squares problem. -- WBR, Timur