casadoj@ecc.es
2004-Dec-14 12:27 UTC
[Rd] R stat functions do not work as stated on the mannual (PR#7419)
Dear R Developers: I have been playing with R, release 2.0.1 for a week now and have detected that all stat functions related to distribution probabilities have the same problem: 1.- According to the manual the log.p parameter is always the last one. 2.- When you use the software, the last parameter seems to be lower.tail Example:> pt (1.1, 5)[1] 0.8392746> pt (1.1, 5, F)[1] 0.8392746> pt (1.1, 5, F, T)[1] 0.8392746>=0DOn this example, I have used the Student T distribution. The result of this example has been tested with the stat calculator at http://calculators.stat.ucla.edu/. 1.- This first line shows that when this function has two arguments, the log.p default value is false, and the lower.tail is true. 2.- The second line shows that when this function has 3 arguments, the last one is the log.p argument and the lower.tail is taken by default to true. 3.- The third line shows that when this function has 4 arguments, the third one keeps on being the log.p argument and the lower.tail is the last one. 4.- Acording to the mannual, the lower.tail should be the third argument and not the last one. Best regards, =0D Jos=E9 Luis Casado Mart=EDnez ------------------------------------------------------------------ European Computing Consultants C/ Hermanos Garc=EDa Noblejas, N=BA 39, 5=AA, N 1 28037 Madrid Telf.: 34-91-406 19 15. Fax: 34-91-406 19 16 Movil: 34-607-750 316 ------------------------------------------------------------------ The last line shows that the sum of probabilities of 1.1 using 5 degrees of freedom adding the lower tail (pt (1.1, 5, F, T)) and not adding the lower tail ( pt (1.1, 5, F, F)) is 1. This is not the case with log (p). _____________________________________________________________________ Mensaje analizado y protegido, tecnologia antivirus www.trendmicro.es [[alternative HTML version deleted]]
murdoch@stats.uwo.ca
2004-Dec-14 12:55 UTC
[Rd] R stat functions do not work as stated on the mannual (PR#7419)
On Tue, 14 Dec 2004 12:27:17 +0100 (CET), casadoj@ecc.es wrote:> >Dear R Developers: > >I have been playing with R, release 2.0.1 for a week now and have detected >that all stat functions related to distribution probabilities have the same> problem: > >1.- According to the manual the log.p parameter is always the last one.Yes, but this is not what you were testing. You seem to have missed the ncp parameter. Is there some documentation somewhere that neglects to mention the ncp parameter? Where?>2.- When you use the software, the last parameter seems to be lower.tail > >Example: > >> pt (1.1, 5) >[1] 0.8392746 >> pt (1.1, 5, F) >[1] 0.8392746Here you're setting ncp=F, not log.p=F or lower.tail=F. ncp is the non-centrality parameter. If you use a logical there, it will be treated as 0.>> pt (1.1, 5, F, T) >[1] 0.8392746Here you have ncp=F and lower.tail = T. Duncan Murdoch>>=0D > >On this example, I have used the Student T distribution. The result of this> example has been tested with the stat calculator at http://calculators.sta>t.ucla.edu/. >1.- This first line shows that when this function has two arguments, the lo>g.p default value is false, and the lower.tail is true. >2.- The second line shows that when this function has 3 arguments, the last> one is the log.p argument and the lower.tail is taken by default to true. >3.- The third line shows that when this function has 4 arguments, the third> one keeps on being the log.p argument and the lower.tail is the last one. >4.- Acording to the mannual, the lower.tail should be the third argument an>d not the last one. > >Best regards, >=0D >Jos=E9 Luis Casado Mart=EDnez >------------------------------------------------------------------ >European Computing Consultants >C/ Hermanos Garc=EDa Noblejas, N=BA 39, 5=AA, N 1 >28037 Madrid >Telf.: 34-91-406 19 15. Fax: 34-91-406 19 16 >Movil: 34-607-750 316 >------------------------------------------------------------------ > >The last line shows that the sum of probabilities of 1.1 using 5 degrees of> freedom adding the lower tail (pt (1.1, 5, F, T)) and not adding the lower> tail ( pt (1.1, 5, F, F)) is 1. This is not the case with log (p).
ligges@statistik.uni-dortmund.de
2004-Dec-14 13:04 UTC
[Rd] R stat functions do not work as stated on the mannual (PR#7419)
casadoj@ecc.es wrote:> Dear R Developers: > > I have been playing with R, release 2.0.1 for a week now and have detected > that all stat functions related to distribution probabilities have the same> problem: > > 1.- According to the manual the log.p parameter is always the last one. > 2.- When you use the software, the last parameter seems to be lower.tail > > Example: > > >>pt (1.1, 5) > > [1] 0.8392746 > >>pt (1.1, 5, F) > > [1] 0.8392746 > >>pt (1.1, 5, F, T) > > [1] 0.8392746 > >>=0D > > > On this example, I have used the Student T distribution. The result of this> example has been tested with the stat calculator at http://calculators.sta> t.ucla.edu/. > 1.- This first line shows that when this function has two arguments, the lo> g.p default value is false, and the lower.tail is true. > 2.- The second line shows that when this function has 3 arguments, the last> one is the log.p argument and the lower.tail is taken by default to true. > 3.- The third line shows that when this function has 4 arguments, the third> one keeps on being the log.p argument and the lower.tail is the last one. > 4.- Acording to the mannual, the lower.tail should be the third argument an> d not the last one.This is your bug!!! Please do read the documentation exactly and do think twice before posting bug reports! According to the manual, pt() has 5 (!!!) arguments: pt(q, df, ncp=0, lower.tail = TRUE, log.p = FALSE) If you do want to use more arguments, why not naming them? It's always much less irritating for yourself to name arguments rather than wild guessing what the hell the 7th argument of foo() was intended to do in your code. See also the corresponding sections in the docs on argument matching. Uwe Ligges> Best regards, > =0D > Jos=E9 Luis Casado Mart=EDnez > ------------------------------------------------------------------ > European Computing Consultants > C/ Hermanos Garc=EDa Noblejas, N=BA 39, 5=AA, N 1 > 28037 Madrid > Telf.: 34-91-406 19 15. Fax: 34-91-406 19 16 > Movil: 34-607-750 316 > ------------------------------------------------------------------ > > The last line shows that the sum of probabilities of 1.1 using 5 degrees of> freedom adding the lower tail (pt (1.1, 5, F, T)) and not adding the lower> tail ( pt (1.1, 5, F, F)) is 1. This is not the case with log (p). > > > > _____________________________________________________________________ > Mensaje analizado y protegido, tecnologia antivirus www.trendmicro.es > [[alternative HTML version deleted]] > > ______________________________________________ > R-devel@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel
Bjørn-Helge Mevik
2004-Dec-15 13:21 UTC
[Rd] R stat functions do not work as stated on the mannual (PR#7419)
> 1.- According to the manual the log.p parameter is always the last one. > 2.- When you use the software, the last parameter seems to be lower.tailAFAIK, R has no concept of "last parameter" in a function call. It has the concept of "first parameter", "second paramter", etc., but not "last".>> pt (1.1, 5) > [1] 0.8392746 >> pt (1.1, 5, F) > [1] 0.8392746 >> pt (1.1, 5, F, T) > [1] 0.8392746 >>=0D> 4.- Acording to the mannual, the lower.tail should be the third argument an> d not the last one.No. According to ?pt or args(pt), pt can take five parameters, the third of which (when they aren't named) is `ncp', not `lower.tail'. What happens in your calls is that your third argument F is converted to 0, which is the default for ncp (and then the T is given to `lower.tail', which is the default value for that parameter). It is often a very good practice to name the arguments explicitly in function calls. Your calls above would be equivalent to pt(q = 1.1, df = 5) pt(q = 1.1, df = 5, ncp = F) # or ncp = 0 pt(q = 1.1, df = 5, ncp = F, lower.tail = T) # or ncp = 0 You will find that pt(q = 1.1, df = 5, lower.tail = F) and pt(q = 1.1, df = 5, lower.tail = F, log.p = T) give quite different answers. -- Bj?rn-Helge Mevik