| Line 37... |
Line 37... |
| 37 |
\code{pf} gives the distribution function
|
37 |
\code{pf} gives the distribution function
|
| 38 |
\code{qf} gives the quantile function, and
|
38 |
\code{qf} gives the quantile function, and
|
| 39 |
\code{rf} generates random deviates.
|
39 |
\code{rf} generates random deviates.
|
| 40 |
|
40 |
|
| 41 |
Invalid arguments will result in return value \code{NaN}, with a warning.
|
41 |
Invalid arguments will result in return value \code{NaN}, with a warning.
|
| 42 |
|
42 |
|
| 43 |
The length of the result is determined by \code{n} for
|
43 |
The length of the result is determined by \code{n} for
|
| 44 |
\code{rf}, and is the maximum of the lengths of the
|
44 |
\code{rf}, and is the maximum of the lengths of the
|
| 45 |
numerical parameters for the other functions.
|
45 |
numerical parameters for the other functions.
|
| 46 |
|
46 |
|
| 47 |
The numerical parameters other than \code{n} are recycled to the
|
47 |
The numerical parameters other than \code{n} are recycled to the
|
| 48 |
length of the result. Only the first elements of the logical
|
48 |
length of the result. Only the first elements of the logical
|
| 49 |
parameters are used.
|
49 |
parameters are used.
|
| 50 |
}
|
50 |
}
|
| 51 |
\details{
|
51 |
\details{
|
| Line 109... |
Line 109... |
| 109 |
\link{Distributions} for other standard distributions, including
|
109 |
\link{Distributions} for other standard distributions, including
|
| 110 |
\code{\link{dchisq}} for chi-squared and \code{\link{dt}} for Student's
|
110 |
\code{\link{dchisq}} for chi-squared and \code{\link{dt}} for Student's
|
| 111 |
t distributions.
|
111 |
t distributions.
|
| 112 |
}
|
112 |
}
|
| 113 |
\examples{
|
113 |
\examples{
|
| - |
|
114 |
## Equivalence of pt(.,nu) with pf(.^2, 1,nu):
|
| - |
|
115 |
x <- seq(0.001, 5, len = 100)
|
| - |
|
116 |
nu <- 4
|
| - |
|
117 |
stopifnot(all.equal(2*pt(x,nu) - 1, pf(x^2, 1,nu)),
|
| - |
|
118 |
## upper tails:
|
| - |
|
119 |
all.equal(2*pt(x, nu, lower=FALSE),
|
| - |
|
120 |
pf(x^2, 1,nu, lower=FALSE)))
|
| - |
|
121 |
|
| 114 |
## the density of the square of a t_m is 2*dt(x, m)/(2*x)
|
122 |
## the density of the square of a t_m is 2*dt(x, m)/(2*x)
|
| 115 |
# check this is the same as the density of F_{1,m}
|
123 |
# check this is the same as the density of F_{1,m}
|
| 116 |
x <- seq(0.001, 5, len = 100)
|
- |
|
| 117 |
all.equal(df(x^2, 1, 5), dt(x, 5)/x)
|
124 |
all.equal(df(x^2, 1, 5), dt(x, 5)/x)
|
| 118 |
|
125 |
|
| 119 |
## Identity: qf(2*p - 1, 1, df)) == qt(p, df)^2) for p >= 1/2
|
126 |
## Identity: qf(2*p - 1, 1, df)) == qt(p, df)^2) for p >= 1/2
|
| 120 |
p <- seq(1/2, .99, length = 50); df <- 10
|
127 |
p <- seq(1/2, .99, length = 50); df <- 10
|
| 121 |
rel.err <- function(x, y) ifelse(x == y, 0, abs(x-y)/mean(abs(c(x,y))))
|
128 |
rel.err <- function(x, y) ifelse(x == y, 0, abs(x-y)/mean(abs(c(x,y))))
|