[Rd] R stat functions do not work as stated on the mannual (PR#7419)

Bjørn-Helge Mevik bhs2 at mevik.net
Wed Dec 15 13:21:19 CET 2004


> 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

AFAIK, 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



More information about the R-devel mailing list