# [R] Initial value choosing in nleqslv package

J C Nash pro|jcn@@h @end|ng |rom gm@||@com
Tue Nov 15 16:19:31 CET 2022

```A rather crude approach to solving nonlinear equations is to rewrite the
equations as residuals and minimize the sum of squares. A zero sumsquares
gives a solution. It is NOT guaranteed to work, of course.

I recommend a Marquardt approach  minpack.lm::nlslm or my nlsr::nlfb. You
will need to specify a function for the jacobian (derivatives of the residuals
w.r.t. the parameters) for the latter package, but it does handle bounds
correctly. Bounds in minpack.lm can be specified but I've a couple of failed
cases, though I'll caution that in this area the scaling is such that all
packages can be made to fail in some cases.

I can send the latest developmental version of the nlsr package with some
updates to make use of jacobians easier if you take that route.

JN

On 2022-11-15 02:49, ASHLIN VARKEY wrote:
> In my work, I use l-moments for estimation and obtain a system of
> nonlinear equations. I am using the 'nleqslv' package in the R- program to
> solve these equations but am struggling to choose initial values. Is there
> any criteria to choose initial values in this package or is there any other
> method to solve these equations?  My system of equations are given below.
>
>   simeqn=function(x){
>
>    y=numeric(4)
>
>    y=x*(((gamma(1+x)*gamma(x-x))/gamma(x))+((gamma(1-
> x)*gamma(x+x))/gamma(x)))- 38353
>
>
> y=x*gamma(1+x)*((gamma(x-x)/gamma(x))-(gamma(2*x-x)/gamma(2*x))-(gamma(x+x)/gamma(x))+(gamma(2*x+x)/gamma(2*x)))-
> 3759.473
>
>
> y=x*gamma(1+x)*((gamma(x-x)/gamma(x))-(3*gamma(2*x-x)/gamma(2*x))+(2*gamma(3*x-x)/gamma(3*x))+(gamma(x+x)/gamma(x))-(3*gamma(2*x+x)/gamma(2*x))+(2*gamma(3*x+x)/gamma(3*x)))-
> 966.3958
>
>    y=
> x*gamma(1+x)*((gamma(x-x)/gamma(x))-(6*gamma(2*x-x)/gamma(2*x))+(10*gamma(3*x-x)/gamma(3*x))-(5*gamma(4*x-x)/gamma(4*x))-(gamma(x+x)/gamma(x))+(6*gamma(2*x+x)/gamma(2*x))-(10*gamma(3*x+x)/gamma(3*x))+(5*gamma(4*x+x)/gamma(4*x)))-
> 500.952
>
>    y
>
> }
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help