[R] Looking for non-central F quantile

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Sat Mar 8 11:15:29 CET 2003


Andrew Robinson <andrewr at uidaho.edu> writes:

> Greetings all,
> 
> I'm trying to figure out how to calculate the inverse CDF (i.e. a
> quantile) for a non-central F distribution.  I could put together a quick
> numerical solver routine using the CDF, but I wonder if there's a function
> that I've missed that would be more efficient?

If we had one, then there would have been an 'ncp' argument to qf()....
In my experience, uniroot() gets you there fast enough in most cases:

> uniroot(function(x)pf(x,ncp=3,4,20)-.995,c(0,1000))$root
[1] 8.301055

(BTW: That chased up a few buglets:

> pf(Inf,ncp=3,4,20)
[1] NaN
Warning message:
NaNs produced in: pnf(q, df1, df2, ncp, lower.tail, log.p)

Whereas

> pf(Inf,4,20)
[1] 1
 
which would also be a sensible result in the noncentral case. Also
-- and what I was trying -- it would be great if uniroot accepted
infinite limits, but it doesn't. Shouldn't be too hard...) 

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907



More information about the R-help mailing list