Skip to content

Commit f39c4f6

Browse files
author
ripley
committed
clean up a bit, including historical remarks
git-svn-id: https://svn.r-project.org/R/trunk@87470 00db46b3-68df-0310-9c12-caf00c1e9a41
1 parent 77699b5 commit f39c4f6

File tree

2 files changed

+24
-31
lines changed

2 files changed

+24
-31
lines changed

src/library/stats/man/fisher.test.Rd

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
% File src/library/stats/man/fisher.test.Rd
22
% Part of the R package, https://www.R-project.org
3-
% Copyright 1995-2022 R Core Team
3+
% Copyright 1995-2024 R Core Team
44
% Distributed under GPL 2 or later
55

66
\name{fisher.test}
@@ -24,17 +24,17 @@ fisher.test(x, y = NULL, workspace = 200000, hybrid = FALSE,
2424
\item{workspace}{an integer specifying the size of the workspace
2525
used in the network algorithm. In units of 4 bytes. Only used for
2626
non-simulated p-values larger than \eqn{2 \times 2}{2 by 2} tables.
27-
Since \R version 3.5.0, this also increases the internal stack size
28-
which allows larger problems to be solved, however sometimes needing
29-
hours. In such cases, \code{simulate.p.values=TRUE} may be more
27+
This also increases the internal stack size
28+
which allows larger problems to be solved, sometimes needing
29+
hours. In such cases, \code{simulate.p.values = TRUE} may be more
3030
reasonable.}
3131
\item{hybrid}{a logical. Only used for larger than \eqn{2 \times 2}{2 by 2}
3232
tables, in which cases it indicates whether the exact probabilities
3333
(default) or a hybrid approximation thereof should be computed.}
3434
\item{hybridPars}{a numeric vector of length 3, by default describing
3535
\dQuote{Cochran's conditions} for the validity of the chi-squared
3636
approximation, see \sQuote{Details}.}
37-
\item{control}{a list with named components for low level algorithm
37+
\item{control}{a list with named components for low-level algorithm
3838
control. At present the only one used is \code{"mult"}, a positive
3939
integer \eqn{\ge 2} with default 30 used only for larger than
4040
\eqn{2 \times 2}{2 by 2} tables. This says how many times as much
@@ -56,7 +56,7 @@ fisher.test(x, y = NULL, workspace = 200000, hybrid = FALSE,
5656
p-values by Monte Carlo simulation, in larger than \eqn{2 \times
5757
2}{2 by 2} tables.}
5858
\item{B}{an integer specifying the number of replicates used in the
59-
Monte Carlo test.}
59+
Monte Carlo test when \code{simulate.p.value} is true.}
6060
}
6161
\value{
6262
A list with class \code{"htest"} containing the following components:
@@ -83,7 +83,7 @@ fisher.test(x, y = NULL, workspace = 200000, hybrid = FALSE,
8383
length. Incomplete cases are removed, vectors are coerced into
8484
factor objects, and the contingency table is computed from these.
8585
86-
For \eqn{2 \times 2}{2 by 2} cases, p-values are obtained directly
86+
For \eqn{2 \times 2}{2 by 2} tables, p-values are obtained directly
8787
using the (central or non-central) hypergeometric
8888
distribution. Otherwise, computations are based on a C version of the
8989
FORTRAN subroutine \code{FEXACT} which implements the network developed by
@@ -105,7 +105,7 @@ fisher.test(x, y = NULL, workspace = 200000, hybrid = FALSE,
105105
alternative for a one-sided test is based on the odds ratio, so
106106
\code{alternative = "greater"} is a test of the odds ratio being bigger
107107
than \code{or}.
108-
108+
%
109109
Two-sided tests are based on the probabilities of the tables, and take
110110
as \sQuote{more extreme} all tables with probabilities less than or
111111
equal to that of the observed table, the p-value being the sum of such
@@ -120,16 +120,9 @@ fisher.test(x, y = NULL, workspace = 200000, hybrid = FALSE,
120120
cells have expected counts at least 5 (\code{= expect}), otherwise
121121
the exact calculation is used. A corresponding \code{if()} decision
122122
is made for all sub-tables considered.
123-
%
124-
Accidentally, \R has used \code{180} instead of \code{80} as
125-
\code{percent}, i.e., \code{hybridPars[2]} in \R versions between
126-
3.0.0 and 3.4.1 (inclusive), i.e., the 2nd of the \code{hybridPars}
127-
(all of which used to be hard-coded previous to \R 3.5.0).
128-
Consequently, in these versions of \R, \code{hybrid=TRUE} never made a
129-
difference.
130123
131124
In the \eqn{r \times c}{r x c} case with \eqn{r > 2} or \eqn{c > 2},
132-
internal tables can get too large for the exact test in which case an
125+
internal tables can be too large for the exact test in which case an
133126
error is signalled. Apart from increasing \code{workspace}
134127
sufficiently, which then may lead to very long running times, using
135128
\code{simulate.p.value = TRUE} may then often be sufficient and hence
@@ -243,7 +236,7 @@ MP6 <- rbind(
243236
c(1,1,2,0,0,0,1),
244237
c(0,1,1,1,1,0,0))
245238
fisher.test(MP6)
246-
# Exactly the same p-value, as Cochran's conditions are never met:
247-
fisher.test(MP6, hybrid=TRUE)
239+
# Exactly the same p-value, as Cochran's conditions are not met:
240+
fisher.test(MP6, hybrid = TRUE)
248241
}
249242
\keyword{htest}

tests/Examples/stats-Ex.Rout.save

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

2-
R Under development (unstable) (2024-11-12 r87322) -- "Unsuffered Consequences"
2+
R Under development (unstable) (2024-12-25 r87467) -- "Unsuffered Consequences"
33
Copyright (C) 2024 The R Foundation for Statistical Computing
4-
Platform: aarch64-apple-darwin24.1.0
4+
Platform: aarch64-apple-darwin24.2.0
55

66
R is free software and comes with ABSOLUTELY NO WARRANTY.
77
You are welcome to redistribute it under certain conditions.
@@ -5124,7 +5124,7 @@ function (V)
51245124
r[seq.int(from = 1L, by = p + 1L, length.out = p)] <- 1
51255125
r
51265126
}
5127-
<bytecode: 0x10b83cec8>
5127+
<bytecode: 0x12090f330>
51285128
<environment: namespace:stats>
51295129
> stopifnot(all.equal(Cl, cov2cor(cov(longley))),
51305130
+ all.equal(cor(longley, method = "kendall"),
@@ -7662,8 +7662,8 @@ data: MP6
76627662
p-value = 0.03929
76637663
alternative hypothesis: two.sided
76647664

7665-
> # Exactly the same p-value, as Cochran's conditions are never met:
7666-
> fisher.test(MP6, hybrid=TRUE)
7665+
> # Exactly the same p-value, as Cochran's conditions are not met:
7666+
> fisher.test(MP6, hybrid = TRUE)
76677667

76687668
Fisher's Exact Test for Count Data hybrid using asym.chisq. iff (exp=5,
76697669
perc=80, Emin=1)
@@ -7772,7 +7772,7 @@ attr(,".Environment")
77727772
> environment(as.formula("y ~ x"))
77737773
<environment: R_GlobalEnv>
77747774
> environment(as.formula("y ~ x", env = new.env()))
7775-
<environment: 0x10d923d98>
7775+
<environment: 0x10699fb68>
77767776
>
77777777
>
77787778
> ## Create a formula for a model with a large number of variables:
@@ -12714,14 +12714,14 @@ attr(,"class")
1271412714
$linkfun
1271512715
function (mu)
1271612716
mu^lambda
12717-
<bytecode: 0x10dce8030>
12718-
<environment: 0x10dcf1fd8>
12717+
<bytecode: 0x12056a680>
12718+
<environment: 0x120575bb0>
1271912719

1272012720
$linkinv
1272112721
function (eta)
1272212722
pmax(eta^(1/lambda), .Machine$double.eps)
12723-
<bytecode: 0x10dce7ee0>
12724-
<environment: 0x10dcf1fd8>
12723+
<bytecode: 0x12056a530>
12724+
<environment: 0x120575bb0>
1272512725

1272612726
>
1272712727
>
@@ -17080,8 +17080,8 @@ Step function with continuity 'f'= 0.2 , 3 knots at
1708017080
> unclass(sfun0)
1708117081
function (v)
1708217082
.approxfun(x, y, v, method, yleft, yright, f, na.rm)
17083-
<bytecode: 0x12c5bc600>
17084-
<environment: 0x10d8ab2d8>
17083+
<bytecode: 0x115d97208>
17084+
<environment: 0x106858c98>
1708517085
attr(,"call")
1708617086
stepfun(1:3, y0, f = 0)
1708717087
> ls(envir = environment(sfun0))
@@ -19647,7 +19647,7 @@ Number of Fisher Scoring iterations: 6
1964719647
> cleanEx()
1964819648
> options(digits = 7L)
1964919649
> base::cat("Time elapsed: ", proc.time() - base::get("ptime", pos = 'CheckExEnv'),"\n")
19650-
Time elapsed: 2.868 0.238 3.12 0 0
19650+
Time elapsed: 2.846 0.215 3.067 0 0
1965119651
> grDevices::dev.off()
1965219652
null device
1965319653
1

0 commit comments

Comments
 (0)