forked from jimhester/GenomicRanges
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/GenomicRanges@66844 bc3139a8-67e5-0310-9ffc-ced21a209358
- Loading branch information
1 parent
5a1eec9
commit 856626f
Showing
2 changed files
with
51 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
\name{phicoef} | ||
|
||
\alias{phicoef} | ||
|
||
\title{Calculate the "phi coefficient" between two binary variables} | ||
|
||
\description{ | ||
The \code{phicoef} function calculates the "phi coefficient" between | ||
two binary variables. | ||
} | ||
|
||
\usage{ | ||
phicoef(x, y=NULL) | ||
} | ||
|
||
\arguments{ | ||
\item{x, y}{ | ||
Two logical vectors of the same length, or, if \code{y} is not supplied, | ||
\code{x} must be a 2x2 integer matrix (or an integer vector of length 4) | ||
representing the contingency table of two binary variables. | ||
} | ||
} | ||
|
||
\value{ | ||
The "phi coefficient" between the two binary variables. | ||
This is a single numeric value ranging from -1 to + 1. | ||
} | ||
|
||
\references{ | ||
\url{http://en.wikipedia.org/wiki/Phi_coefficient} | ||
} | ||
|
||
\author{ | ||
H. Pages | ||
} | ||
|
||
\examples{ | ||
set.seed(33) | ||
x <- sample(c(TRUE, FALSE), 100, replace=TRUE) | ||
y <- sample(c(TRUE, FALSE), 100, replace=TRUE) | ||
phicoef(x, y) | ||
phicoef(rep(x, 10), c(rep(x, 9), y)) | ||
|
||
stopifnot(phicoef(table(x, y)) == phicoef(x, y)) | ||
stopifnot(phicoef(x, !y) == - phicoef(x, y)) | ||
stopifnot(phicoef(x, x) == 1) | ||
} | ||
|
||
\keyword{manip} |