s-news
[Top] [All Lists]

Re: Problems with "uniroot"

To: <gerald.jean@dgag.ca>
Subject: Re: Problems with "uniroot"
From: "Dimitris Rizopoulos" <dimitrios.rizopoulos@student.kuleuven.ac.be>
Date: Wed, 27 Jul 2005 16:45:54 +0200
Cc: <s-news@wubios.wustl.edu>
References: <OF36D18E03.63DEA0EB-ON8525704B.004F8B72@spgdag.ca>
try it this way:

SeuilGamma <- function(x, mu, shape, rate, kk) mu * (pgamma(x, shape + 1, rate) - kk) + x * (1 - pgamma(x, shape, rate)) uniroot(f = SeuilGamma, lower = 440, upper = 450, mu = 7462.83, shape = 0.4475635, rate = 5.997237e-05, kk = 0.05)

observe that uniroot() has an argument `keep.xy'

I hope it helps.

Best,
Dimitris

----
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/16/336899
Fax: +32/16/337015
Web: http://www.med.kuleuven.be/biostat/
    http://www.student.kuleuven.be/~m0390867/dimitris.htm


----- Original Message ----- From: <gerald.jean@dgag.ca>
To: <s-news@wubios.wustl.edu>
Sent: Wednesday, July 27, 2005 4:37 PM
Subject: [S] Problems with "uniroot"


Hello,

I am struggling to find the root of a non-linear monotone function.
"uniroot" is complaining about a missing argument?

uniroot(f = SeuilGamma, lower = 440, upper = 450,
+         f.lower = -0.2724897, f.upper = 7.515328,
+ mu = 7462.83, shape = 0.4475635, rate = 5.997237e-05, k = 0.05)

Problem in f(440.349892242598, mu = 7462.83, shape = 0.44..: argument "k"
is missing with no default
Use traceback() to see the call stack

traceback()

11: eval(action, sys.parent())
10: doErrorAction("Problem in f(440.349892242598, mu = 7462.83, shape =
0.44..: argument \"k\" is missing with no default",
9: pgamma(x, shape + 1, rate) - k
8: mu * (pgamma(x, shape + 1, rate) - k)
7: mu * (pgamma(x, shape + 1, rate) - k) + x * (1 - pgamma(x, shape, rate))
6: f(440.349892242598, mu = 7462.83, shape = 0.4475635, rate =
5.997237e-05)
5: eval(this.call, local = sys.parent(1.))
4: do.call("f", c(list(old$z), newdots))
3: uniroot.1k(f, temp, newargs(dots, fnames, temp$aux))
2: uniroot(f = SeuilGamma, lower = 440, upper = 450, f.lower = -0.2724897,
f.upper = 7.515328,
1:
Message: Problem in f(440.349892242598, mu = 7462.83, shape = 0.44..:
argument "k" is missing with no default

and here is my fonction "GammaSeuil".

"SeuilGamma" <- function(x, mu, shape, rate, k)
{
mu * (pgamma(x, shape + 1, rate) - k) + x * (1 - pgamma(x, shape, rate))
}

I know I could pretty easily find the zero by other means but I have to do this several thousand of times and it would be nice if it could be done by a builtin function. There is something I must be missing since I never had
luck with "uniroot"!

Thanks,

Gérald Jean
Analyste-conseil (statistiques), Actuariat
télephone            : (418) 835-4900 poste (7639)
télecopieur          : (418) 835-6657
courrier électronique: gerald.jean@dgag.ca

"In God we trust, all others must bring data"  W. Edwards Deming


--------------------------------------------------------------------
This message was distributed by s-news@lists.biostat.wustl.edu.  To
unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
the BODY of the message:  unsubscribe s-news


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