Ken Kelley <[EMAIL PROTECTED]> wrote

>
>
> I have a problem that I have been unable to determine either the best
> way to proceed and why the methods I'm trying to use sometimes fail. I'm
> using the pf() function in an optimization function to find a
> noncentrality parameter that leads to a specific value at a specified
> quantile.
[SNIP]
> I'm using three function [optim(), optimize(), and nlm()] to try and
> accomplish the same goal (which was stated above). I believe that they
> should all return the same value, and at times they do just that, but at
> other times the methods return inappropriate results. I'll paste my code
> that illustrates an example where all is well and one where things fail.
>

Perhaps uniroot() might be better
 Low.Lim.NC.F <- function(Lambda, alpha.lower, F.value, df.1, df.2) {
    pf(q=F.value, df1=df.1, df2=df.2, ncp=Lambda) - (1-alpha.lower)
 }
 uniroot(Low.Lim.NC.F, interval=c(0,50000), alpha.lower=0.025, df.1=5,
 df.2=200, F.value=12)

If you plot your example, the gradients are much steeper from above than
below, so nlm() works when the starting value is say 50.  In addition,
underflow in pf for more extreme values of lambda affect these more
general search algorithms.


| David Duffy (MBBS PhD)                                         ,-_|\
| email: [EMAIL PROTECTED]  ph: INT+61+7+3362-0217 fax: -0101  /     *
| Epidemiology Unit, Queensland Institute of Medical Research   \_,-._/
| 300 Herston Rd, Brisbane, Queensland 4029, Australia  GPG 4D0B994A v

______________________________________________
R-help@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

Reply via email to