[R] solving system of nonlinear equations
Spencer Graves
spencer.graves at pdf.com
Mon Nov 15 02:09:06 CET 2004
Have you considered "nls"? If you read the help file and work
through the examples, there is a good chance you can make it work, I
think. I think I would start trying "plinear" in "nls", parameterizing
the problem in terms of alpha, beta, ln.sigma, and ln.tau, unless you
think a solution might require sigma < 0 or tau < 0. Using logarithms
will get rid of the constraint and may make the problem numerically
easier. Using alpha and beta rather than lambda and delta transforms
the problem into an ordinary least squares problem for alpha and beta
given any two numbers for sigma and tau (or ln.sigma and ln.tau).
If I had trouble with this, I might try two other things:
(a) The "solver" in Excel.
(b) I might generate a grid in ln.sigma and ln.tau using
expand.grid. For each combination of levels, I'd set up the linear
regression problem and use "lm" to estimate alpha and beta and compute
and store the sum of squares of residuals. Then I'd use "contour" to
visualize the sum of squares surface.
I've done all these things with crudely similar problems in the
past and been happy with the results. If I only had this one problem,
I'd be surprised if it would require more than a few hours. If I wanted
a general algorithm for other purposes, I might do it two or three
different ways both to help select a good algorithm and to build
confidence in the results.
hope this helps.
spencer graves
p.s. Some of these techniques are discussed in Venables and Ripley
(2002) Modern Applied Statistics with S, 4th ed. (Springer). If you
don't have this, I'd encourage you to consider spending some time with it.
Enayetur RAHEEM wrote:
>Hello there
>
>Can anybody please tell me if there is any package in R to solve the
>following 4 nonlinear equations with 4 unknowns:
>
>alpha*exp(20/sigma)+ beta*exp(21/tau) = 2
>alpha*exp(22/sigma)+ beta*exp(9/tau) = 4
>alpha*exp(10/sigma)+ beta*exp(30/tau) = 6
>alpha*exp(40/sigma)+ beta*exp(39/tau) = 5
>
>where
>
>alpha = exp(lambda/sigma)
>beta= exp(delta/tau)
>
>I need to estimate lambda, sigma, delta, tau
>
>Thanks.
>E Raheem
>
>______________________________________________
>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
>
>
--
Spencer Graves, PhD, Senior Development Engineer
O: (408)938-4420; mobile: (408)655-4567
More information about the R-help
mailing list