Prof Brian Ripley wrote:
On Sun, 12 Oct 2008, Peter Dalgaard wrote:
Prof Brian Ripley wrote:
Please do RTFM, for the help says
df: degrees of freedom (> 0, maybe non-integer). 'df = Inf' is
allowed. For 'qt' only values of at least one are currently
supported.
On Sun, 12 Oct 2008, Enrico Rossi wrote:
Sorry about the html-formatted message. Here it is again in plain text.
Hello,
The function qt returns NaN for degrees of freedom <1. For example:
qt(0.5,0.5)
[1] NaN
Warning message:
In qt(p, df, lower.tail, log.p) : NaNs produced
But qt(0.5,0.5) should be 0, since the distribution is symmetric.
pt(0,0.5)
[1] 0.5
It actually fails with any value, as long as df<1.
Is this a bug, or is there some fundamental reason why this cannot be
computed?
Neither ....
Well, presumably, it is using an algorithm that only works for df >=1.
However, qf() works fine with df1 < 1, so there's a fairly easy
workaround.
Are you referring to
If X ~ t(df) then X^2 ~ F(1, df)
? That needs df2 < 1. So the workaround is
fake_qt <- function(p, df)
sign(p-0.5) * sqrt(qf(2*min(p, 1-p), 1, df, lower=FALSE))
Yes, that's what I meant. For some reason I couldn't come up with the
compact expression at the time.
(df1 was a typo, but not actually wrong since 1/F(1,df) ~ F(df,1)...)
Another workaround is qt(x, df, ncp=1e-10)
Somewhat easier, yes!
--
O__ ---- Peter Dalgaard Ă˜ster Farimagsgade 5, Entr.B
c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.