Package samplesizecmh

Similar documents
Package pwrab. R topics documented: June 6, Type Package Title Power Analysis for AB Testing Version 0.1.0

Package datasets.load

Package fastdummies. January 8, 2018

Package cattonum. R topics documented: May 2, Type Package Version Title Encode Categorical Features

Package ECctmc. May 1, 2018

Package validara. October 19, 2017

Package bisect. April 16, 2018

Package SEMrushR. November 3, 2018

Package epitab. July 4, 2018

Package jdx. R topics documented: January 9, Type Package Title 'Java' Data Exchange for 'R' and 'rjava'

Package geojsonsf. R topics documented: January 11, Type Package Title GeoJSON to Simple Feature Converter Version 1.3.

Package strat. November 23, 2016

Package censusapi. August 19, 2018

Package balance. October 12, 2018

Package gggenes. R topics documented: November 7, Title Draw Gene Arrow Maps in 'ggplot2' Version 0.3.2

Package spelling. December 18, 2017

Package canvasxpress

Package ggimage. R topics documented: December 5, Title Use Image in 'ggplot2' Version 0.1.0

Package modmarg. R topics documented:

Package fingertipsr. May 25, Type Package Version Title Fingertips Data for Public Health

Package ggimage. R topics documented: November 1, Title Use Image in 'ggplot2' Version 0.0.7

Package spark. July 21, 2017

Package raker. October 10, 2017

Package gtrendsr. October 19, 2017

Package docxtools. July 6, 2018

Package embed. November 19, 2018

Package editdata. October 7, 2017

Package robotstxt. November 12, 2017

Package knitrprogressbar

Package simsurv. May 18, 2018

Package readxl. April 18, 2017

Package gtrendsr. August 4, 2018

Package postgistools

Package splithalf. March 17, 2018

Package crossrun. October 8, 2018

Package wrswor. R topics documented: February 2, Type Package

Package barcoder. October 26, 2018

Package calpassapi. August 25, 2018

Package vinereg. August 10, 2018

Package deductive. June 2, 2017

Package fastrtext. December 10, 2017

Package WordR. September 7, 2017

Package fastqcr. April 11, 2017

Package semver. January 6, 2017

Package SIMLR. December 1, 2017

Package liftr. R topics documented: May 14, Type Package

Package ThreeArmedTrials

Package datapasta. January 24, 2018

Package kdtools. April 26, 2018

Package projector. February 27, 2018

Package bigreadr. R topics documented: August 13, Version Date Title Read Large Text Files

Package eply. April 6, 2018

Package PTE. October 10, 2017

Package messaging. May 27, 2018

Package nngeo. September 29, 2018

Package rprojroot. January 3, Title Finding Files in Project Subdirectories Version 1.3-2

Package UNF. June 13, 2017

Package TrafficBDE. March 1, 2018

Package optimus. March 24, 2017

Package CorporaCoCo. R topics documented: November 23, 2017

Package fusionclust. September 19, 2017

Package stapler. November 27, 2017

Package internetarchive

Package mgc. April 13, 2018

Package nmslibr. April 14, 2018

Package MatchIt. April 18, 2017

Package lumberjack. R topics documented: July 20, 2018

Package RNAseqNet. May 16, 2017

R topics documented: 2 genbernoullidata

Package kirby21.base

Package ggmosaic. February 9, 2017

Package effectr. January 17, 2018

Package triebeard. August 29, 2016

Package apastyle. March 29, 2017

Package redux. May 31, 2018

Package dkanr. July 12, 2018

Package goodpractice

Package diffusr. May 17, 2018

Package colf. October 9, 2017

Package ClusterBootstrap

Package facerec. May 14, 2018

Package ezsummary. August 29, 2016

Package quickreg. R topics documented:

Package snakecase. R topics documented: March 25, Version Date Title Convert Strings into any Case

Package zoomgrid. January 3, 2019

Package repec. August 31, 2018

Package sfc. August 29, 2016

Package shinyfeedback

Package mmpa. March 22, 2017

Package MUS. November 29, 2017

Package rsppfp. November 20, 2018

Package wikitaxa. December 21, 2017

Package CuCubes. December 9, 2016

Package BiocManager. November 13, 2018

Package preprosim. July 26, 2016

Package rgho. R topics documented: January 18, 2017

Package opencage. January 16, 2018

Package climber. R topics documented:

Package sgmcmc. September 26, Type Package

Package pdfsearch. July 10, 2018

Transcription:

Package samplesizecmh Title Power and Sample Size Calculation for the Cochran-Mantel-Haenszel Test Date 2017-12-13 Version 0.0.0 Copyright Spectrum Health, Grand Rapids, MI December 21, 2017 Calculates the power and sample size for Cochran-Mantel-Haenszel tests. There are also several helper functions for working with probability, odds, relative risk, and odds ratio values. Depends R (>= 3.4.0) Imports stats License GPL-2 GPL-3 Encoding UTF-8 LazyData true Suggests knitr, rmarkdown, DescTools, datasets, testthat VignetteBuilder knitr RoxygenNote 6.0.1 URL https://github.com/pegeler/samplesizecmh BugReports https://github.com/pegeler/samplesizecmh/issues NeedsCompilation no Author Paul Egeler [aut, cre], Spectrum Health, Grand Rapids, MI [cph] Maintainer Paul Egeler <paul.egeler@spectrumhealth.org> Repository CRAN Date/Publication 2017-12-21 15:15:57 UTC 1

2 contraceptives R topics documented: contraceptives........................................ 2 odds.and.proportions.................................... 3 odds.ratio.......................................... 4 power.cmh.test....................................... 5 print.power.cmh....................................... 7 rel.risk............................................ 8 samplesizecmh....................................... 8 Index 10 contraceptives Oral contraceptive use and breast cancer rates This data summarizes counts of a case-control study investigating the link between breast cancer rates and oral contraceptive use, stratified by age group. In toto, 10,890 subjects. See source for details. data(contraceptives) Format A 3-dimensional table. 1. OC : Subject exposure to oral contraceptives. 2. Disease Status: Breast cancer present (case) or absent (control). 3. Age Group: Age group of the subject. Source Hennekens, C. H., F. E. Speizer, R. J. Lipnick, B. Rosner, C. Bain, C. Belanger, M. J. Stampfer, W. Willett, and R. Peto. (1984). "A Case-Control Study of Oral Contraceptive Use and Breast Cancer." Journal of the National Cancer Institute 72 (1): 39 42. Table 1.

odds.and.proportions 3 odds.and.proportions Interconvert odds and proportion values These functions will create either odds for a given probability, probability for a given odds, calculate the odds ratio between two probabilities, or calculate effect size (raise a probability by theta) prop2odds(p) odds2prop(o) effect.size(p, theta) props2theta(p1, p2) rr2theta(rr, p1, p2) theta2rr(theta, p1, p2) p, p1, p2 Proportion vector. o theta rr Value A numeric vector. Author(s) Paul W. Egeler, M.S. Examples Odds vector. Odds ratio vector. Relative risk vector (p1 / p2). # Convert proportions of 0 through 1 to odds props <- seq(0,1,0.1) prop2odds(props) # Convert odds to proportions odds2prop(1:3) # Raise a proportion by an effect size theta

4 odds.ratio effect.size(0.5, 2) # Find the odds ratio between to proportions props2theta(0.75, 0.5) odds.ratio Create an odds ratio estimate from a 2-by-2 table of frequencies or proportions Create an odds ratio estimate from a 2-by-2 table of frequencies or proportions odds.ratio(x) x A two-dimensional matrix or table containing frequencies or proportions. Value A numeric vector. Author(s) Paul W. Egeler, M.S. Examples # Load in Titanic data from datasets package data(titanic, package = "datasets") # Get marginal table of survival by sex marginal_table <- margin.table(titanic, c(2,4)) marginal_table # Compute odds ratio of marginal table odds.ratio(marginal_table) # Get partial tables of survival by sex, stratified by class partial_tables <- margin.table(titanic, c(2,4,1)) partial_tables # Compute odds ratio of each partial table apply(partial_tables, 3, odds.ratio)

power.cmh.test 5 power.cmh.test Power and sample size calculation for the Cochran-Mantel-Haenszel test Compute the post-hoc power or required number of subjects for the Cochran-Mantel-Haenszel test for association in J stratified 2 x 2 tables. power.cmh.test(p1 = NULL, p2 = NULL, theta = NULL, N = NULL, sig.level = 0.05, power = 0.8, alternative = c("two.sided", "less", "greater"), s = 0.5, t = 1/J, correct = TRUE) p1 p2 theta N sig.level power alternative s t correct Vector of proportions of the J case groups. Vector of proportions of the J control groups. Vector of odds ratios relating to the J 2 x 2 tables. Total number of subjects. Significance level (Type I error probability). Power of test (1 minus Type II error probability). Two- or one-sided test. If one-sided, the direction of the association must be defined (less than 1 or greater than 1). Can be abbreviated. Proportion (weight) of case versus control in J stratum. Proportion (weight) of total number of cases of J stratum. Logical indicating whether to apply continuity correction. Details This sample size calculation is based on the derivations described in the Woolson et al. (1986). It is designed for case-control studies where one margin is fixed. The method is "based on the Cochran-Mantel-Haenszel statistic expressed as a weighted difference in binomial proportions." Continuity corrected sample size is described in Nam s 1992 paper. This uses the weighted binomial sample size calculation described in Woolson et al. (1986) but is enhanced for use with the continuity corrected Cochran s test. Power calculations are based on the writings of Wittes and Wallenstein (1987). They are functionally equivalent to the derivations of the sample size calculation described by Woolson and others and Nam, but have slightly added precision. Terminology and symbolic conventions are borrowed from Woolson et al. (1986). The p1 group is dubbed the Case group and p2 group is called the Control group.

6 power.cmh.test Value An object of class "power.cmh": a list of the original arguments and the calculated sample size or power. Also included are vectors of n s per each group, an indicator or whether continuity correction was used, the original function call, and N.effective. The vectors of n s per each group, n1 and n2, are the fractional n s required to achieve a final total N specified by the calculation while satisfying the constraints of s and t. However, the effective N, given the requirement of cell counts populated by whole numbers is provided by N.effective. By default, the print method is set to n.frac = FALSE, which will round each cell n up to the nearest whole number. To calculate power, the power parameter must be set to NULL. To calculate sample size, the N parameter must be set to NULL. The J number of groups will be inferred by the maximum length of p1, p2, or theta. Effect size must be specified using one of the following combinations of arguments. Both case and control proportion vectors, ex., p1 and p2 with theta = NULL. One proportion vector and an effect size, ex., p1 and theta with p2 = NULL, or p2 and theta with p1 = NULL. Author(s) Paul W. Egeler, M.S. References Gail, M. (1973). "The determination of sample sizes for trials involving several 2 x 2 tables." Journal of Chronic Disease 26: 669-673. Munoz, A. and B. Rosner. (1984). "Power and sample size for a collection of 2 x 2 tables." Biometrics 40: 995-1004. Nam, J. (1992). "Sample size determination for case-control studies and the comparison of stratified and unstratified analyses." Biometrics 48: 389-395. Wittes, J. and S. Wallenstein. (1987). "The power of the Mantel-Haenszel test." Journal of the American Statistical Association 82: 1104-1109. Woolson, R. F., Bean, J. A., and P. B. Rojas. (1986). "Sample size for case-control studies using Cochran s statistic." Biometrics 42: 927-932. See Also power.prop.test, mantelhaen.test, BreslowDayTest

print.power.cmh 7 Examples # From "Sample size determination for case-control studies and the comparison # of stratified and unstratified analyses", (Nam 1992). See references. # Uncorrected sample size estimate first introduced # by Woolson and others in 1986 sample_size_uncorrected <- power.cmh.test( p2 = c(0.75,0.70,0.65,0.60), theta = 3, power = 0.9, t = c(0.10,0.40,0.35,0.15), alternative = "greater", correct = FALSE ) print(sample_size_uncorrected, detail = FALSE) # We see that the N is 171, the same as calculated by Nam sample_size_uncorrected$n # Continuity corrected sample size estimate added by Nam sample_size_corrected <- power.cmh.test( p2 = c(0.75,0.70,0.65,0.60), theta = 3, power = 0.9, t = c(0.10,0.40,0.35,0.15), alternative = "greater", correct = TRUE ) print(sample_size_corrected, n.frac = TRUE) # We see that the N is indeed equal to that which is reported in the paper sample_size_corrected$n print.power.cmh Print power.cmh object Print power.cmh object ## S3 method for class 'power.cmh' print(x, detail = TRUE, n.frac = FALSE,...)

8 samplesizecmh x detail n.frac... Ignored. A "power.cmh" object. Logical to toggle detailed or simple output. Logical indicating whether sample n s should be rounded to the next whole number. rel.risk Calculate the relative risk from a 2-by-2 table Computes the relative risk of a specified column of a two-by-two table. rel.risk(x, col.num = 1) x col.num A table or matrix containing frequencies. The column number upon which relative risk should be calculated. Value A numeric vector. Author(s) Paul W. Egeler, M.S. samplesizecmh samplesizecmh: Power and Sample Size Calculation for the Cochran- Mantel-Haenszel Test This package provides functions relating to power and sample size calculation for the CMH test. There are also several helper functions for interconverting probability, odds, relative risk, and odds ratio values.

samplesizecmh 9 Details The Cochran-Mantel-Haenszel test (CMH) is an inferential test for the association between two binary variables, while controlling for a third confounding nominal variable. Two variables of interest, X and Y, are compared at each level of the confounder variable Z and the results are combined, creating a common odds ratio. Essentially, the CMH test examines the weighted association of X and Y. The CMH test is a common technique in the field of biostatistics, where it is often used for case-control studies. Sample Size Calculation Given a target power which the researcher would like to achieve, a calculation can be performed in order to estimate the appropriate number of subjects for a study. The power.cmh.test function calculates the required number of subjects per group to achieve a specified power for a Cochran- Mantel-Haenszel test. Power Calculation Researchers interested in estimating the probability of detecting a true positive result from an inferential test must perform a power calculation using a known sample size, effect size, significance level, et cetera. The power.cmh.test function can compute the power of a CMH test, given parameters from the experiment.

Index Topic datasets contraceptives, 2 BreslowDayTest, 6 contraceptives, 2 effect.size (odds.and.proportions), 3 mantelhaen.test, 6 odds.and.proportions, 3 odds.ratio, 4 odds2prop (odds.and.proportions), 3 power.cmh.test, 5, 9 power.prop.test, 6 print.power.cmh, 7 prop2odds (odds.and.proportions), 3 props2theta (odds.and.proportions), 3 rel.risk, 8 rr2theta (odds.and.proportions), 3 samplesizecmh, 8 samplesizecmh-package (samplesizecmh), 8 theta2rr (odds.and.proportions), 3 10