Description Usage Arguments Details Value Author(s) See Also Examples
Takes in a list of strata, and returns a stratified table of counts (can also include other descriptives as specified by the user) as well as the chi-squared summaries for each. Relies on the Exact
package for calculating Odds Ratios and Risk Ratios, the plyr
package for array manipulation, and the survival
package for censored data analysis.
1 2 3 4 5 6 7 | ## S3 method for class 'tabulate'
tabulate(..., dispRatios=FALSE, stratified=TRUE, tests=NULL,
stat="count", na.rm=TRUE, subset=NULL, probs= c(.25,.50,.75),
replaceZeroes=FALSE, restriction=Inf, above=NULL,
below=NULL, labove=NULL, rbelow=NULL, lbetween=NULL, rbetween=NULL,
interval=NULL, linterval=NULL, rinterval=NULL, lrinterval=NULL,
version=FALSE)
|
... |
a list of strata variables. All variables must have the same length. |
dispRatios |
can only be used if the first two variables only take on two values. Default is |
stratified |
default is |
tests |
the type of tests to include in addition to the chi-squared test. Options are |
stat, na.rm, subset, probs, replaceZeroes, restriction, above, below, labove, rbelow, lbetween, rbetween, interval, linterval, rinterval, lrinterval, version |
variables passed to |
If stratified=TRUE
, prints the stratified count tables and chi-squared summaries. The printed result is a matrix with columns for (if appropriate): the point estimate, test statistic, degrees of freedom, 95% confidence interval, p-value, and any warnings in computation. If requested, row/column/total percentages are also stratified based on the first two variables entered. If stratified=FALSE
, then the overall chi-squared statistic is returned and percentages are calculated from the overall table. If specified the user can also display Odds Ratio/Risk Ratio, likelihood-ratio test, Fisher's Exact test, Wald test, Barnard's Unconditional Exact test, Rao's Score test, and Mantel-Haenszel test results. The Mantel-Haenzsel chi-squared estimate, confidence interval, and estimate of the odds ratio are only returned if the first three variables entered into tabulate()
are 2 by 2 by K. Any call to tabulate()
will run tabulate.default()
, with user specified values in place of the appropriate defaults.
Returns an object of class tabulate
. Contains two values in a list:
rslt |
the raw result, which has all of the tables of counts. |
printer |
the raw result with descriptive statistics, if specified. |
Scott S. Emerson, M.D., Ph.D., Andrew J. Spieker, Brian D. Williamson, Travis Y. Hee Wai, and Solomon Lim
exact.test
, fisher.test
, aaply
, descrip
, tableStat
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | ## load the necessary libraries
library(survival)
library(Exact)
library(plyr)
## read in the mri dataset
mri <- read.table("http://www.emersonstatistics.com/datasets/mri.txt",header=TRUE)
## attach the mri dataset
attach(mri)
## create a table of stroke and race
tabulate(stroke, race)
## perform a chi-squared test of stroke vs race, display the count, row percentage,
## and column percentage
tabulate(stroke, race, stat="@count@ @row%@ @col%@")
## perform chi-squared test, likelihood ratio test, and fisher's exact test
## for stroke vs race
tabulate(stroke, race, tests=c("lrchisq", "fisher"))
## for diabetes vs male by race, perform chi-squared test, display
## odds ratio/risk ratio, mantel-haenzsel, likelihood ratio chi-squared
tabulate(diabetes, male, race, dispRatios=TRUE, tests=c("lrchisq", "mh"))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.