s-news
[Top] [All Lists]

Re: Solving NonLinear Equations

To: "'Bert Jacobs'" <b.jacobs@pandora.be>, <s-news@lists.biostat.wustl.edu>
Subject: Re: Solving NonLinear Equations
From: "Alan Hochberg" <alan.hochberg@prosanos.com>
Date: Thu, 7 Sep 2006 17:29:27 -0400
In-reply-to: <20060907205517.46E152300DA@adicia.telenet-ops.be>
Thread-index: AcbR3FSoW5wP5SsSTuSOV8m7EzIhuQAsx0+AAAjMQSAAAzEToAAAccaw
Uniroot() finds "a" solution in an interval, not necessarily "the" solution
that you want.  There may be multiple roots, some of which meet your
constraints.  Since you've got R or S-plus which have great graphical tools,
I would suggest that you plot y, c, d, and the residual (which I called
"resid") over various ranges of x, and get some insight into how your
function behaves, and where the roots are (the zero-crossings of resid).
Then you will be able to tell if there are roots in a region of x that
satisfies any constraints you might want to add.  You can then find the root
that lies in the correct interval by changing the interval searched by
uniroot().  I hard-coded this interval as c(-9999.0,9999.0).  (Violating my
own rule against hard-coding constants!)

I don't know where these equations have arisen from, but sometimes plotting
a function can give you more insight into the problem you're trying to solve
than you would get by root-finding alone.

Alan




<Prev in Thread] Current Thread [Next in Thread>