You need to add keep.xy=T to your function call because your function has
extra arguments in addition to x (see help page on uniroot):
uniroot(f = SeuilGamma, lower = 440, upper = 450,
+ f.lower = -0.2724897, f.upper = 7.515328, keep.xy = T,
+ mu = 7462.83, shape = 0.4475635, rate = 5.997237e-05, k =
+ 0.05)
-Christos
-----Original Message-----
From: s-news-owner@lists.biostat.wustl.edu
[mailto:s-news-owner@lists.biostat.wustl.edu] On Behalf Of
gerald.jean@dgag.ca
Sent: Wednesday, July 27, 2005 10:37 AM
To: s-news@wubios.wustl.edu
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
|