| Title: | Data and Functions for Introduction to Biostatistics with R |
|---|---|
| Description: | Provides datasets and supporting functions for the book "Introduction to Biostatistics with R" by Schifano and Yan (2026+), published by Taylor & Francis. The package is intended for teaching introductory biostatistics and for reproducing examples in the text. |
| Authors: | Elizabeth Schifano [aut, cph] (ORCID: <https://orcid.org/0000-0002-9793-332X>), Jun Yan [aut, cre, cph] (ORCID: <https://orcid.org/0000-0003-4401-7296>) |
| Maintainer: | Jun Yan <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 0.1-1 |
| Built: | 2026-10-16 21:32:38 UTC |
| Source: | https://github.com/ibist/ibist-r |
Reconstructed paired observer ratings for three clinical grading scales used after aneurysmal subarachnoid hemorrhage: WFNS, Hunt and Hess (HH), and PAASH.
A data frame with 309 rows (103 paired ratings for each of 3 scales) and 4 variables:
Grading scale: WFNS, HH, or PAASH.
Sequential row number within scale. These numbers are generated for the reconstructed data and are not study participant IDs.
Ordered factor giving the first observer's grade (1–5).
Ordered factor giving the second observer's grade (1–5).
The paired ratings are expanded from the published cross-tabulations. They reproduce the observed cell counts for each scale and can be used to illustrate agreement summaries such as kappa. The original participant-level records are not available here; generated rows cannot be linked across scales.
Degen, L. A. R., Dorhout Mees, S. M., Algra, A., and Rinkel, G. J. E. (2011). Interobserver variability of grading scales for aneurysmal subarachnoid hemorrhage. Stroke, 42(6), 1546–1549. doi:10.1161/STROKEAHA.110.601211
data(asah) wfns <- subset(asah, scale == "WFNS") table(wfns$observer1, wfns$observer2) # irr::kappa2(wfns[c("observer1", "observer2")], weight = "squared")data(asah) wfns <- subset(asah, scale == "WFNS") table(wfns$observer1, wfns$observer2) # irr::kappa2(wfns[c("observer1", "observer2")], weight = "squared")
Tests for a linear trend in a binary outcome across ordered groups using the Cochran-Armitage statistic. The test can use a normal approximation or an exact conditional distribution.
ca.trend.test( x, scores = NULL, alternative = c("two.sided", "greater", "less"), exact = FALSE )ca.trend.test( x, scores = NULL, alternative = c("two.sided", "greater", "less"), exact = FALSE )
x |
An |
scores |
Optional numeric scores for the ordered groups. Defaults to
|
alternative |
Alternative hypothesis: |
exact |
Logical; if |
A positive signed statistic indicates that the event proportion tends to
increase with the group scores. The exact test conditions on the row totals
and the total number of events and uses the conditional distribution of
. For a two-sided exact test, the p-value is
twice the smaller one-sided tail probability, truncated at one. The exact
calculation is performed by dynamic programming and can become slow when
the table has many rows or large margins.
An object of class "htest". The signed Cochran-Armitage statistic
is returned along with its square, the score statistic , the
p-value, and the alternative hypothesis.
Cochran, W. G. (1954). Some methods for strengthening the common chi-squared tests. Biometrics, 10(4), 417–451. doi:10.2307/3001616
Armitage, P. (1955). Tests for linear trends in proportions and frequencies. Biometrics, 11(3), 375–386. doi:10.2307/3001775
Portier, C., and Hoel, D. G. (1984). Type 1 error of trend tests in proportions and the design of cancer screens. Communications in Statistics - Theory and Methods, 13(1), 1–14.
tab <- matrix(c(106, 109, 128, 130, 99, 95, 76, 74), nrow = 4) ca.trend.test(tab) ca.trend.test(tab, scores = c(1, 2, 4, 8), alternative = "greater") small.tab <- matrix(c(2, 0, 1, 1, 0, 2), nrow = 3, byrow = TRUE) ca.trend.test(small.tab, exact = TRUE)tab <- matrix(c(106, 109, 128, 130, 99, 95, 76, 74), nrow = 4) ca.trend.test(tab) ca.trend.test(tab, scores = c(1, 2, 4, 8), alternative = "greater") small.tab <- matrix(c(2, 0, 1, 1, 0, 2), nrow = 3, byrow = TRUE) ca.trend.test(small.tab, exact = TRUE)
Tests for a zero score correlation in an RxC contingency table using the Cochran-Mantel-Haenszel linear-by-linear statistic.
cmh.ll.test( x, measure = c("pearson", "spearman"), alternative = c("two.sided", "greater", "less"), row.scores = NULL, col.scores = NULL )cmh.ll.test( x, measure = c("pearson", "spearman"), alternative = c("two.sided", "greater", "less"), row.scores = NULL, col.scores = NULL )
x |
A two-dimensional matrix or table of non-negative integer counts. Rows and columns must be ordered from the lowest to highest category. |
measure |
The score correlation to test: |
alternative |
Alternative hypothesis: |
row.scores, col.scores
|
Optional numeric scores for row and column
categories when |
Let be the Pearson correlation between the assigned row and column
scores (or their marginal midranks for Spearman correlation). The signed
test statistic is , and the CMH statistic is
, which has an asymptotic chi-squared distribution with one
degree of freedom under the null hypothesis. One-sided tests use the signed
normal statistic. This function tests zero association only; it does not
return a confidence interval. Use ordinal.assoc() for the
multinomial-based Wald confidence interval for Pearson or Spearman
correlation. Those intervals are not obtained by inverting this test. The
Pearson and Spearman tests in ordinal.assoc() use their own
multinomial null variances and are distinct from this CMH test; their
p-values can differ.
An object of class "htest". The statistic element contains
the signed statistic, and the chisq element contains its
square, the CMH statistic. The estimate element contains the score
correlation.
Mantel, N. (1963). Chi-square tests with one degree of freedom: extensions of the Mantel-Haenszel procedure. Journal of the American Statistical Association, 58(303), 690–700. doi:10.1080/01621459.1963.10500879
tab <- matrix(c(109, 68, 14, 72, 79, 37, 9, 42, 139), nrow = 3, byrow = TRUE) cmh.ll.test(tab, measure = "pearson") cmh.ll.test(tab, measure = "spearman", alternative = "greater") ordinal.assoc(tab, measure = "spearman")tab <- matrix(c(109, 68, 14, 72, 79, 37, 9, 42, 139), nrow = 3, byrow = TRUE) cmh.ll.test(tab, measure = "pearson") cmh.ll.test(tab, measure = "spearman", alternative = "greater") ordinal.assoc(tab, measure = "spearman")
Computes Cohen's kappa or weighted kappa from a square table of paired
ratings, with a Wald confidence interval and an asymptotic test of
.
cohen.kappa.test( x, weights = "unweighted", conf.level = 0.95, alternative = c("two.sided", "greater", "less"), test.variance = c("fce", "delta") )cohen.kappa.test( x, weights = "unweighted", conf.level = 0.95, alternative = c("two.sided", "greater", "less"), test.variance = c("fce", "delta") )
x |
A square matrix or table of non-negative integer counts. Rows and columns represent the same ordered rating categories. |
weights |
The agreement weights: |
conf.level |
Confidence level for the two-sided Wald confidence interval. |
alternative |
Alternative hypothesis: |
test.variance |
Variance used for the test: |
The confidence interval uses the Fleiss–Cohen–Everitt (FCE) large-sample
variance of the kappa estimate. This variance is algebraically equivalent
to the multinomial delta-method variance used by
psych::cohen.kappa(). By default, the test uses the distinct FCE
variance under the null hypothesis . Setting
test.variance = "delta" instead uses the delta-method variance
evaluated at the observed cell proportions. Evaluating the delta-method
variance under the null gives the FCE null variance, so it is not a separate
test option. The interval is an untruncated Wald interval.
This function provides asymptotic inference only. SAS PROC FREQ
also provides exact tests for simple and weighted kappa; exact inference is
not implemented here.
An object of class "htest" containing the estimate,
confidence interval, Z statistic, and p-value. It also includes the
standard error used for the confidence interval, the standard error under
the null hypothesis, the selected test variance method, the weight
matrix, and the sample size.
Fleiss, J. L., Cohen, J., and Everitt, B. S. (1969). Large sample standard errors of kappa and weighted kappa. Psychological Bulletin, 72(5), 323–327. doi:10.1037/h0028106
SAS Institute Inc. (2015). Tests and measures of agreement. In Base SAS 9.4 Procedures Guide: Statistical Procedures, Third Edition. https://support.sas.com/documentation/cdl/en/procstat/67528/HTML/default/procstat_freq_details76.htm
peff <- matrix( c(581, 134, 12, 6, 0, 2, 91, 73, 18, 31, 3, 1, 4, 18, 15, 19, 3, 3, 1, 8, 7, 24, 11, 6, 0, 0, 2, 4, 3, 5, 0, 0, 0, 9, 11, 13), nrow = 6, byrow = TRUE ) cohen.kappa.test(peff) cohen.kappa.test(peff, weights = "quadratic") cohen.kappa.test(peff, weights = "quadratic", test.variance = "delta")peff <- matrix( c(581, 134, 12, 6, 0, 2, 91, 73, 18, 31, 3, 1, 4, 18, 15, 19, 3, 3, 1, 8, 7, 24, 11, 6, 0, 0, 2, 4, 3, 5, 0, 0, 0, 9, 11, 13), nrow = 6, byrow = TRUE ) cohen.kappa.test(peff) cohen.kappa.test(peff, weights = "quadratic") cohen.kappa.test(peff, weights = "quadratic", test.variance = "delta")
The demo_clt() function generates plots to illustrate the
Central Limit Theorem (CLT) using a specified random number generator.
The function displays standardized sampling distributions for
different sample sizes and overlays the standard normal density.
demo_clt(rng, n, nrep = 10000, ..., pmean = NULL, psd = NULL)demo_clt(rng, n, nrep = 10000, ..., pmean = NULL, psd = NULL)
rng |
A random number generator function taking the sample size
as its first argument (e.g., |
n |
A numeric vector of sample sizes (e.g., |
nrep |
The number of repetitions for generating sample means (default is 10000). |
... |
Additional arguments passed to the random number generator
(e.g., |
pmean |
The population mean of the distribution. If |
psd |
The population standard deviation of the distribution.
If |
A ggplot2 object showing the standardized sampling
distributions for different sample sizes, compared against the
standard normal curve.
set.seed(123) demo_clt(runif, n = c(5, 20), nrep = 100, min = 0, max = 1, pmean = 0.5, psd = sqrt(1 / 12)) demo_clt(rgamma, n = c(5, 20), shape = 2, rate = 1, nrep = 100, pmean = 2, psd = sqrt(2) )set.seed(123) demo_clt(runif, n = c(5, 20), nrep = 100, min = 0, max = 1, pmean = 0.5, psd = sqrt(1 / 12)) demo_clt(rgamma, n = c(5, 20), shape = 2, rate = 1, nrep = 100, pmean = 2, psd = sqrt(2) )
This dataset is derived from a longitudinal study examining the role of insomnia and cognitive intrusions in predicting future depression. It includes participants who were not depressed at baseline and who met inclusion criteria on age, missingness, and stress exposure.
depressdepress
A data frame with 1730 observations and 9 variables:
Age in years.
Gender of the participant (coded per original survey).
Indicator for experiencing at least one stressor in the past year.
Depression status at 1-year follow-up.
Depression status at 2-year follow-up.
Depression at either 1 or 2 years.
Tertile of cognitive intrusion score based on the Impact of Event Scale (IES).
Grouped cognitive intrusion: 0 = lowest tertile, 1 = middle tertile, 2 = highest tertile.
Insomnia indicator defined as: sleep onset latency (SOL) > 30 minutes or wake after sleep onset (WASO) > 30 minutes.
The dataset is constructed by applying the following criteria:
Baseline depression score < 10.
Age >= 18.
Non-missing gender, cognitive intrusion (IES), and WASO.
At least one stressor in the past year.
Exclusion of extreme nocturnal wakefulness (> 90 minutes).
The resulting dataset (n = 1730) includes all three cognitive
intrusion tertiles. In the original paper, the analytic sample was
further restricted by removing observations with missing
IEStert, which effectively excludes the middle tertile
(coded as IESgrp = 1), yielding a smaller sample
(n = 1126). This optional restriction is not applied here but can be
reproduced by subsetting:
depress_paper <- subset(depress, !is.na(IEStert))
Variable definitions follow the original study documentation provided in the supplementary spreadsheet (S1 Table).
Kalmbach, D. A., Pillai, V., and Drake, C. L. (2018). Nocturnal insomnia symptoms and stress-induced cognitive intrusions in risk for depression: a 2-year prospective study. PLOS ONE, 13(2), e0192088.
Kalmbach, D. A., Pillai, V., and Drake, C. L. (2018). Nocturnal insomnia symptoms and stress-induced cognitive intrusions in risk for depression: a 2-year prospective study. PLOS ONE, 13(2), e0192088.
data(depress) str(depress) # proportion developing depression within 2 years mean(depress$depress1or2yr) # insomnia prevalence mean(depress$insom) # reproduce analytic sample used in the paper depress_paper <- subset(depress, !is.na(IEStert))data(depress) str(depress) # proportion developing depression within 2 years mean(depress$depress1or2yr) # insomnia prevalence mean(depress$insom) # reproduce analytic sample used in the paper depress_paper <- subset(depress, !is.na(IEStert))
These data arise from a prospective study examining the association between dental fluorosis and amoxicillin use during early childhood.
fluorosisfluorosis
A data frame with 24 rows and 5 variables:
Oral hygiene measure (factor with levels 0, 1)
Fluoride level (factor with levels 1, 2, 3)
Amoxicillin use during early childhood (factor: 0 = no, 1 = yes)
Dental fluorosis status (factor: 0 = absent, 1 = present)
Number of subjects in the corresponding cell
Dental fluorosis — a developmental defect of tooth enamel — was assessed as a binary outcome (presence or absence) when participants were approximately 9 years old. Information on fluoride intake, infections, and amoxicillin use during early childhood (birth to 32 months) was collected as part of the Iowa Fluoride Study.
The dataset is provided in aggregated form as a four-way contingency table with cell counts.
The data have a 2 x 3 x 2 x 2 factorial structure: oral hygiene (2 levels), fluoride level (3 levels), amoxicillin use (2 levels), and fluorosis status (2 levels). The counts sum to 308 subjects.
Hong L, Levy SM, Warren JJ, Dawson DV, Bergus GR, Wefel JS (2005). Association of amoxicillin use during early childhood with developmental tooth enamel defects. Archives of Pediatrics & Adolescent Medicine, 159(10), 943–948.
data(fluorosis) with(fluorosis, xtabs(count ~ om + fl_lev + amox + fluorosis))data(fluorosis) with(fluorosis, xtabs(count ~ om + fl_lev + amox + fluorosis))
Performs the Pearson chi-squared goodness-of-fit (GoF) test for a
logistic regression model fitted via glm(..., family = "binomial").
The test assesses calibration by comparing observed and expected
counts across covariate patterns.
logistic.gof(fit, min_n = 5, min_expected = 5, pool = TRUE) logistic_gof(...)logistic.gof(fit, min_n = 5, min_expected = 5, pool = TRUE) logistic_gof(...)
fit |
A fitted |
min_n |
Minimum total count per group for pooling. Default is 5. |
min_expected |
Minimum expected count per group for pooling. Default is 5. |
pool |
Logical; if |
... |
Arguments passed to |
The Pearson GoF statistic is defined as
where is the observed number of events, is the expected number of events, and
is the
variance for the -th covariate pattern. Under the null
hypothesis of correct model specification, approximately
follows a chi-squared distribution with degrees of
freedom, where is the number of groups and is the
number of model parameters.
This test requires replicated covariate patterns or grouped binomial data. When groups are small, optional pooling can be applied to ensure stable chi-squared approximation.
The function supports three types of binomial responses:
Binary outcomes (0/1)
Proportions with weights (grouped binomial)
Two-column matrix response via cbind(success, failure)
When no replication exists (i.e., each observation has a unique covariate pattern), the Pearson GoF test is not appropriate. In such cases, consider alternative methods such as the Hosmer–Lemeshow test.
Pooling stabilizes the test by merging adjacent groups with small counts, trading a small bias for reduced variance in the chi-squared approximation.
An object of class "ibist_logistic_gof" and "htest"
with components:
statistic |
The Pearson chi-squared and deviance statistics. |
parameter |
Degrees of freedom. |
p.value |
The corresponding p-values. |
method |
Description of the test. |
data.name |
Description of the data. |
Additional components (not printed) include:
observed |
Observed counts by group. |
expected |
Expected counts by group. |
group_n |
Group sizes. |
groups |
Data frame of grouped summaries. |
## Example: Surfactant use and birthweight (RDS data) data(rds, package = "ibist") fit <- glm(death ~ surf + bwt, data = rds, weights = count, family = "binomial" ) ## Pearson GoF test with pooling (default) (res <- logistic.gof(fit)) ## Without pooling (may be unstable if small groups exist) logistic.gof(fit, pool = FALSE) ## Inspect grouped diagnostics res$groups## Example: Surfactant use and birthweight (RDS data) data(rds, package = "ibist") fit <- glm(death ~ surf + bwt, data = rds, weights = count, family = "binomial" ) ## Pearson GoF test with pooling (default) (res <- logistic.gof(fit)) ## Without pooling (may be unstable if small groups exist) logistic.gof(fit, pool = FALSE) ## Inspect grouped diagnostics res$groups
Checks whether the large-sample condition for the Mantel-Haenszel test is satisfied for a collection of stratified 2 x 2 tables.
mantelhaen.asymcheck(x)mantelhaen.asymcheck(x)
x |
A list of 2 x 2 tables, or a 2 x 2 x K array of non-negative integer counts. Rows are the two groups and columns are the two outcome categories. |
Conditional on the margins of stratum , the upper-left cell count
has hypergeometric variance
The chi-squared approximation used by the Mantel-Haenszel test is considered adequate when
This diagnostic applies to the asymptotic test. It is not required for an
exact conditional test such as or.common.test.
An object of class "ibist_mantelhaen_asymcheck" containing:
variance |
the hypergeometric variance for each stratum. |
variance.sum |
the sum of the stratum-specific variances. |
condition.met |
a logical value indicating whether the sum is at least 5. |
data.name |
a character string describing the data. |
mantelhaen.test,
or.common.test
strat <- array( c(88, 469, 48, 653, 27, 480, 34, 1324), dim = c(2, 2, 2) ) mantelhaen.asymcheck(strat)strat <- array( c(88, 469, 48, 653, 27, 480, 34, 1324), dim = c(2, 2, 2) ) mantelhaen.asymcheck(strat)
Aggregated data of cases and person-years by diastolic blood pressure category and gender.
midbpmidbp
A data frame with 16 rows and 4 variables:
Diastolic blood pressure category (1–8).
Gender (Men, Women).
Number of observed cases.
Person-years of follow-up.
The dataset is aggregated by DBP category and gender, suitable for rate modeling (e.g., Poisson regression with offset).
The DBP categories are coded as: 1 = <70 mmHg, 2 = 70–74 mmHg, 3 = 75–79 mmHg, 4 = 80–84 mmHg, 5 = 85–89 mmHg, 6 = 90–94 mmHg, 7 = 95–99 mmHg, and 8 = >=100 mmHg.
data(midbp) head(midbp)data(midbp) head(midbp)
Aggregated data on event counts and person-years by HDL cholesterol category and gender. Suitable for Poisson rate modeling and incidence rate comparisons.
mihdlmihdl
A data frame with 24 rows and 4 variables:
HDL category (integer, 1–12)
Gender (factor: Men, Women)
Number of events
Person-years at risk
The dataset provides grouped count data for modeling rates using Poisson regression with an offset for log person-years.
data(mihdl) fit <- glm(cases ~ factor(hdl) + gender, offset = log(pyears), family = poisson, data = mihdl) summary(fit)data(mihdl) fit <- glm(cases ~ factor(hdl) + gender, offset = log(pyears), family = poisson, data = mihdl) summary(fit)
A large observational dataset from a cohort study conducted in Japan to examine the association between non-restorative sleep (NRS) and physical activity, gender, and age. The data are used to illustrate logistic regression modeling for a binary outcome in a large-sample setting.
nrsnrs
A data frame with 91,795 subjects (90,122 complete records) on the following variables:#'
Subject identifier.
Gender of the subject (F = Female; M = Male).
Age in years in 2013.
Indicator of regular exercise in 2013 (integer-coded).
Physical activity measure in 2013 (integer-coded).
Indicator of non-restorative sleep in 2013 (1 = presence; 0 = absence).
Non-restorative sleep (NRS) is defined as a subjective feeling of lack of refreshment on awakening and reflects qualitative aspects of sleep. Hidaka et al. (2019) analyzed these data using logistic regression to assess whether the probability of NRS is associated with physical activity, gender, and age in a large cohort of adult subjects in Japan. Within this package, the dataset is provided for methodological illustration of binary regression models rather than for substantive epidemiological inference.
Missing values are represented as NA, which are present in
'ex', 'pa', and 'nrs'.
Hidaka et al. (2019).
data(nrs) summary(nrs)data(nrs) summary(nrs)
Computes confidence intervals for the odds ratio in a 2 x 2 table.
or.2x2.ci( x, conf.level = 0.95, method = c("wald", "gart", "cornfield", "bp"), midp = FALSE, ... )or.2x2.ci( x, conf.level = 0.95, method = c("wald", "gart", "cornfield", "bp"), midp = FALSE, ... )
x |
A 2 x 2 table of non-negative integer counts. |
conf.level |
Confidence level for the interval. |
method |
Method or methods for confidence interval. One or more of
|
midp |
Logical; should the conditional exact method be modified using
mid-p probabilities? The default is |
... |
Reserved for future extensions. |
For a table with entries , , , and
, the sample odds ratio is
.
The "wald" method uses the usual large-sample interval on the
log odds-ratio scale. The addition of 0.5 to every cell is the
Haldane–Anscombe correction, introduced independently by Haldane (1956)
and Anscombe (1956). The "gart" method applies this correction
using the interval construction in Gart (1966). The "cornfield" method
inverts two one-sided conditional tests, while the "bp" method
inverts a two-sided conditional test ordered
by null probabilities. Both use the noncentral hypergeometric distribution.
Setting midp = TRUE subtracts half the observed-table probability
from the corresponding exact p-value. Exact intervals are conservative;
mid-p intervals are not guaranteed to attain at least the nominal coverage
level.
An object of class "ibist_ci" containing the common estimate
and a confidence-limit matrix with one row per method.
Anscombe, F. J. (1956). On estimating binomial response relations. Biometrika, 43(3–4), 461–464. doi:10.1093/biomet/43.3-4.461
Baptista, J., and Pike, M. C. (1977). Algorithm AS 115: Exact two-sided confidence limits for the odds ratio in a 2 x 2 table. Journal of the Royal Statistical Society. Series C, 26(2), 214–220.
Fagerland, M. W., Lydersen, S., and Laake, P. (2015). Recommended confidence intervals for two independent binomial proportions. Statistical Methods in Medical Research, 24(2), 224–254.
Gart, J. J. (1966). Alternative analyses of contingency tables. Journal of the Royal Statistical Society: Series B, 28(1), 164–179.
Haldane, J. B. S. (1956). The estimation and significance of the logarithm of a ratio of frequencies. Annals of Human Genetics, 20(4), 309–311. doi:10.1111/j.1469-1809.1955.tb01285.x
tab <- matrix(c(7, 27, 1, 33), nrow = 2, byrow = TRUE) or.2x2.ci(tab) or.2x2.ci(tab, method = "gart") or.2x2.ci(tab, method = "cornfield") or.2x2.ci(tab, method = "bp", midp = TRUE)tab <- matrix(c(7, 27, 1, 33), nrow = 2, byrow = TRUE) or.2x2.ci(tab) or.2x2.ci(tab, method = "gart") or.2x2.ci(tab, method = "cornfield") or.2x2.ci(tab, method = "bp", midp = TRUE)
Computes an exact conditional test or confidence interval for a common odds ratio across a collection of 2 x 2 tables.
or.common.test( x, theta = 1, alternative = c("two.sided", "greater", "less"), ... ) or.common.ci( x, conf.level = 0.95, algorithm = c("network", "convolution"), ... ) or.homogeneity.test(x, ...)or.common.test( x, theta = 1, alternative = c("two.sided", "greater", "less"), ... ) or.common.ci( x, conf.level = 0.95, algorithm = c("network", "convolution"), ... ) or.homogeneity.test(x, ...)
x |
A list of 2 x 2 tables, or a 2 x 2 x K array of non-negative integer counts. Rows are the two groups and columns are the two outcome categories. |
theta |
The null common odds ratio. |
alternative |
A character string specifying the alternative
hypothesis: |
... |
Reserved for future extensions. |
conf.level |
Confidence level for the interval. |
algorithm |
Computational algorithm for the exact confidence interval.
The default, |
Conditional on the margins of every stratum, the upper-left cell in each
table has a noncentral hypergeometric distribution. The test combines the
strata through the sum of those upper-left cells. The two-sided test uses
the Jung et al. (2014) rule
,
truncated at one. The confidence interval is obtained by inverting these
one-sided exact tests.
or.homogeneity.test() performs Zelen's exact test of
. It conditions on the observed sum
of the upper-left cells, which removes the unspecified common odds ratio
from the null distribution. The two-sided p-value uses probability
ordering.
All three procedures are exact conditional procedures; none is an asymptotic alternative. The first two procedures test or estimate a common odds ratio. The homogeneity procedure tests whether the stratum-specific odds ratios are equal, without specifying their common value.
or.common.test() returns an object of class "htest".
or.common.ci() returns an object of class "ibist_ci".
or.homogeneity.test() returns an object of class "htest".
Jung, S. H., Biggerstaff, B. J., and Kim, C. (2014). A class of exact tests for a common odds ratio in stratified 2 x 2 tables. Biometrical Journal, 56(1), 97–109. doi:10.1002/bimj.201300048
Mehta, C. R., Patel, N. R., and Gray, R. (1985). On computing an exact confidence interval for the common odds ratio in several 2 x 2 contingency tables. Journal of the American Statistical Association, 80(392), 969–973. doi:10.1080/01621459.1985.10478212
Zelen, M. (1971). The analysis of several 2 x 2 contingency tables. Biometrika, 58(1), 129–137. doi:10.1093/biomet/58.1.129
tabs <- list( matrix(c(7, 3, 2, 8), nrow = 2, byrow = TRUE), matrix(c(4, 6, 1, 9), nrow = 2, byrow = TRUE) ) or.common.test(tabs) or.common.ci(tabs) or.homogeneity.test(tabs)tabs <- list( matrix(c(7, 3, 2, 8), nrow = 2, byrow = TRUE), matrix(c(4, 6, 1, 9), nrow = 2, byrow = TRUE) ) or.common.test(tabs) or.common.ci(tabs) or.homogeneity.test(tabs)
Computes confidence intervals for the conditional odds ratio from a 2 x 2 table of matched pairs.
or.paired.ci( x, conf.level = 0.95, method = c("wald", "wilson", "clopper-pearson", "midp", "blaker") )or.paired.ci( x, conf.level = 0.95, method = c("wald", "wilson", "clopper-pearson", "midp", "blaker") )
x |
A 2 x 2 table of non-negative integer pair counts. Rows describe
the first member of each pair and columns the second, with the positive
category first in both dimensions. Thus |
conf.level |
Confidence level for the intervals. |
method |
One or more of |
Write and . The matched-pair odds ratio
is estimated by , not by the cross-product ratio of the pair-count
table. Concordant pairs do not contribute information about this
conditional odds ratio. Transposing the table or reversing both binary
category orders reciprocates the odds ratio. Reversing only one category
order changes which pairs are discordant and is not the same analysis.
The "wald" interval is
.
It equals the asymptotic Mantel–Haenszel interval when each pair is
represented as an individual stratum. It requires both discordant counts
to be positive; zero concordant counts are allowed.
Conditional on , is binomial with success probability
. The remaining methods transform binomial
probability limits to .
The Wilson method inverts the score test, Clopper–Pearson inverts
equal-tailed exact tests, and mid-p subtracts half the observed mass from
each inclusive tail. Blaker's method takes the smallest interval
containing the acceptance set of its exact two-sided test. Its
acceptability statistic is the smaller inclusive binomial tail, and its
p-value sums probabilities of outcomes with acceptability no larger
than the observed value.
Clopper–Pearson and Blaker intervals have at least nominal conditional
coverage; Wald, Wilson, and mid-p intervals have no such guarantee.
With only one nonzero discordant count the estimate is zero or infinity,
and transformed intervals remain available. With no discordant pairs,
the odds ratio is unidentified: the estimate is NA, transformed
intervals are c(0, Inf), and a warning is issued.
This function estimates a conditional matched-pair odds ratio, not a
marginal odds ratio or a difference of paired proportions. For the latter,
use prop.paired.ci().
An object of class "ibist_ci" with a matched-pair odds-ratio
estimate and one confidence-limit row per requested method.
Fagerland, M. W., Lydersen, S., and Laake, P. (2014). Recommended tests and confidence intervals for paired binomial proportions. Statistics in Medicine, 33, 2850–2875. doi:10.1002/sim.6148
Blaker, H. (2000). Confidence curves and improved exact confidence intervals for discrete distributions. Canadian Journal of Statistics, 28, 783–798. doi:10.2307/3315916
twins <- matrix(c(51, 30, 10, 41), nrow = 2, byrow = TRUE) or.paired.ci(twins) or.paired.ci(twins, method = c("wilson", "clopper-pearson", "midp", "blaker")) or.paired.ci(matrix(c(8, 4, 0, 6), 2, byrow = TRUE), method = "wilson")twins <- matrix(c(51, 30, 10, 41), nrow = 2, byrow = TRUE) or.paired.ci(twins) or.paired.ci(twins, method = c("wilson", "clopper-pearson", "midp", "blaker")) or.paired.ci(matrix(c(8, 4, 0, 6), 2, byrow = TRUE), method = "wilson")
Computes ordinal association measures and their asymptotic confidence intervals from an RxC table. It also tests the null hypothesis that each association measure is zero.
ordinal.assoc( x, measure = c( "gamma", "tau-b", "tau-c", "somers-c|r", "somers-r|c", "pearson", "spearman" ), conf.level = 0.95, alternative = c("two.sided", "greater", "less"), row.scores = NULL, col.scores = NULL )ordinal.assoc( x, measure = c( "gamma", "tau-b", "tau-c", "somers-c|r", "somers-r|c", "pearson", "spearman" ), conf.level = 0.95, alternative = c("two.sided", "greater", "less"), row.scores = NULL, col.scores = NULL )
x |
A two-dimensional matrix or table of non-negative integer counts. Rows and columns must be ordered from the lowest to highest category. |
measure |
One or more measures: |
conf.level |
Confidence level for the two-sided asymptotic confidence intervals. |
alternative |
Alternative hypothesis for the tests:
|
row.scores, col.scores
|
Optional numeric scores for row and column categories when computing Pearson correlation. By default, numeric category labels are used; otherwise, category order numbers are used. Spearman correlation always uses marginal midrank scores. |
The procedure computes the concordant and discordant pair counts, n_C and n_D, and sets S = n_C - n_D. Its null variance is
where A_ij and D_ij are the concordant and discordant contributions for cell (i,j). The test statistic is Z = S/sqrt(Var_0(S)).
The concordance-based measures share a test statistic, but Pearson and Spearman correlations use their own multinomial null variances. Standard errors and confidence intervals are computed separately for each measure. Confidence intervals are two-sided regardless of the test alternative. Rows and columns with zero marginal totals are dropped before computation.
The "somers-c|r" measure is Somers' Delta(C|R), treating the row
variable as explanatory; "somers-r|c" is Delta(R|C), treating the
column variable as explanatory.
Pearson correlation uses the supplied category scores or the default category scores described above (numeric labels such as 1, 2, and 10 are used as-is). Spearman correlation uses marginal midranks, so observations tied within a category receive the same rank. The correlation standard errors and null variances use multinomial contingency-table formulas. The confidence intervals are Wald intervals.
An object of class "ibist_ordinal_assoc" containing:
Named vector of selected association estimates.
Named vector of asymptotic standard errors.
Matrix of lower and upper confidence limits.
Named asymptotic test statistics, one per selected measure.
Named p-values, one per selected measure.
The observed concordance contrast and its null variance.
Concordant and discordant pair counts.
Brown, M. B., and Benedetti, J. K. (1977). Sampling behavior of tests for correlation in two-way contingency tables. Journal of the American Statistical Association, 72(358), 309–315.
Goodman, L. A., and Kruskal, W. H. (1954). Measures of association for cross classifications. Journal of the American Statistical Association, 49(268), 732–764.
Kendall, M. G. (1970). Rank Correlation Methods (4th ed.). Griffin.
Somers, R. H. (1962). A new asymmetric measure of association for ordinal variables. American Sociological Review, 27(6), 799–811.
Stuart, A. (1953). The estimation and comparison of strengths of association in contingency tables. Biometrika, 40(1–2), 105–110.
tab <- matrix(c(12, 3, 1, 4, 9, 2, 1, 5, 13), nrow = 3, byrow = TRUE) ordinal.assoc(tab) ordinal.assoc( tab, measure = c("tau-b", "somers-c|r", "pearson", "spearman") )tab <- matrix(c(12, 3, 1, 4, 9, 2, 1, 5, 13), nrow = 3, byrow = TRUE) ordinal.assoc(tab) ordinal.assoc( tab, measure = c("tau-b", "somers-c|r", "pearson", "spearman") )
Computes power, sample size, or detectable effect size for a
one-sample binomial test. The interface mirrors
stats::power.prop.test(), but for the one-sample setting.
power.p1s.test( n = NULL, p0 = NULL, p1 = NULL, power = NULL, sig.level = 0.05, alternative = c("two.sided", "less", "greater"), correct = FALSE, exact = FALSE, exact.method = c("quantile", "midp", "midp-rand", "cp"), strict = FALSE, tol = .Machine$double.eps^0.5, max_n = 1e+07, size.rule = c("close", "minimal"), alpha.min.frac = 0.9 )power.p1s.test( n = NULL, p0 = NULL, p1 = NULL, power = NULL, sig.level = 0.05, alternative = c("two.sided", "less", "greater"), correct = FALSE, exact = FALSE, exact.method = c("quantile", "midp", "midp-rand", "cp"), strict = FALSE, tol = .Machine$double.eps^0.5, max_n = 1e+07, size.rule = c("close", "minimal"), alpha.min.frac = 0.9 )
n |
Sample size for the single group. |
p0 |
Null hypothesis proportion. |
p1 |
Alternative hypothesis proportion. |
power |
Desired power. |
sig.level |
Significance level. |
alternative |
Character string specifying the alternative
hypothesis; one of |
correct |
Logical; if |
exact |
Logical; if |
exact.method |
Method used for exact binomial power calculation.
|
strict |
Logical; if |
tol |
Numerical tolerance used in root finding. |
max_n |
Maximum allowable sample size when solving for |
size.rule |
Character string specifying the rule used to select
the sample size when
where
|
alpha.min.frac |
Numeric value in (0, 1) specifying the minimum
fraction of the nominal significance level required for the achieved
level when The achieved significance level must satisfy
The default value See also |
Power can be computed using a normal approximation or exact binomial
methods. When exact = TRUE, the exact test is determined by
exact.method.
For exact.method = "quantile", the one-sided critical boundary is
the most extreme binomial quantile whose null tail probability does not
exceed sig.level. For a two-sided test, up to half of
sig.level is allocated to each tail.
For exact.method = "midp", the lower and upper mid-p tails at an
observed count are, respectively,
and
A one-sided test rejects when the applicable mid-p tail is no greater than
sig.level. The central two-sided test implemented here rejects when
twice the smaller mid-p tail is no greater than sig.level. Other
two-sided mid-p tests may use different orderings of the sample space. Power
and
achieved.sig.level are the full probabilities of this deterministic
rejection region under and , respectively. Unlike the
other deterministic exact methods, a mid-p test need not control its actual
size at the nominal level for every .
For exact.method = "midp-rand", the quantile method's critical
boundaries are retained, but an observation on either boundary is assigned
rejection probability one-half. Thus, each reported probability consists
of the probability strictly beyond the boundaries plus one-half of the
boundary mass. This randomized construction explains its connection to
mid-p tail probabilities.
For exact.method = "cp", rejection is determined by the one-sided
exact binomial p-value or, for a two-sided test, twice the smaller exact
tail probability. This is equivalent to inversion of the corresponding
Clopper–Pearson acceptance region and controls size at
sig.level.
Exactly one of n, p0, p1, power, or
sig.level must be NULL; the missing quantity is solved
numerically.
An object of class "power.htest" containing the computed
quantity and test specifications. For exact calculations,
achieved.sig.level is the null rejection probability. With
exact.method = "midp-rand", it includes the one-half randomized
contribution at each boundary.
## Normal approximation (default) power.p1s.test(n = 50, p0 = 0.1, p1 = 0.25) ## Exact binomial power (quantile-based, default exact method) power.p1s.test(n = 50, p0 = 0.1, p1 = 0.25, exact = TRUE) ## Exact power for the deterministic mid-p test power.p1s.test( n = 50, p0 = 0.1, p1 = 0.25, exact = TRUE, exact.method = "midp" ) ## Randomized mid-p power at the quantile rejection boundaries power.p1s.test( n = 50, p0 = 0.1, p1 = 0.25, exact = TRUE, exact.method = "midp-rand" ) ## Exact Clopper--Pearson power (guaranteed size control) power.p1s.test( n = 50, p0 = 0.1, p1 = 0.25, exact = TRUE, exact.method = "cp" )## Normal approximation (default) power.p1s.test(n = 50, p0 = 0.1, p1 = 0.25) ## Exact binomial power (quantile-based, default exact method) power.p1s.test(n = 50, p0 = 0.1, p1 = 0.25, exact = TRUE) ## Exact power for the deterministic mid-p test power.p1s.test( n = 50, p0 = 0.1, p1 = 0.25, exact = TRUE, exact.method = "midp" ) ## Randomized mid-p power at the quantile rejection boundaries power.p1s.test( n = 50, p0 = 0.1, p1 = 0.25, exact = TRUE, exact.method = "midp-rand" ) ## Exact Clopper--Pearson power (guaranteed size control) power.p1s.test( n = 50, p0 = 0.1, p1 = 0.25, exact = TRUE, exact.method = "cp" )
Computes power, sample size, detectable proportions, or significance level for a two-sample test comparing proportions, allowing unequal group sizes through a user-specified allocation ratio.
power.p2s.test( n = NULL, p1 = NULL, p2 = NULL, sig.level = 0.05, power = NULL, group.rate = 1, alternative = c("two.sided", "one.sided"), correct = FALSE, strict = FALSE, tol = .Machine$double.eps^0.25 )power.p2s.test( n = NULL, p1 = NULL, p2 = NULL, sig.level = 0.05, power = NULL, group.rate = 1, alternative = c("two.sided", "one.sided"), correct = FALSE, strict = FALSE, tol = .Machine$double.eps^0.25 )
n |
Sample size in the first group. The second group size is
|
p1 |
Proportion in the first group. |
p2 |
Proportion in the second group. |
sig.level |
Significance level (type I error rate), must be in
|
power |
Target power of the test. |
group.rate |
Ratio of sample sizes between the second and first
groups, defined as |
alternative |
Character string specifying the alternative
hypothesis, either |
correct |
Logical; if |
strict |
Logical; if |
tol |
Tolerance for numerical root-finding when solving for an unknown parameter. |
Exactly one of n, p1, p2, power, or
sig.level must be NULL, and that parameter is solved
from the others.
The calculation is based on the normal approximation to the binomial
distribution. Let and .
The test statistic uses a pooled variance under the null and an
unpooled variance under the alternative.
When strict = TRUE for a two-sided test, power is computed as
the sum of tail probabilities. Otherwise, a one-sided approximation
is used.
The code is adapted from stats::power.power.test() by allowing different group sizes and continuity correction.
An object of class "power.htest" with components:
n |
Sample size in the first group. |
p1 |
Proportion in the first group. |
p2 |
Proportion in the second group. |
sig.level |
Significance level. |
power |
Power of the test. |
alternative |
Type of alternative hypothesis. |
note |
Clarifies that |
method |
Description of the method. |
This function generalizes stats::power.prop.test() by allowing
unequal group sizes through group.rate. When
group.rate = 1, the two functions are equivalent.
# Power with unequal group sizes (n2 = 2 * n1) power.p2s.test(n = 100, p1 = 0.3, p2 = 0.5, group.rate = 2) # Required sample size in group 1 power.p2s.test(p1 = 0.3, p2 = 0.5, power = 0.8, group.rate = 1.5)# Power with unequal group sizes (n2 = 2 * n1) power.p2s.test(n = 100, p1 = 0.3, p2 = 0.5, group.rate = 2) # Required sample size in group 1 power.p2s.test(p1 = 0.3, p2 = 0.5, power = 0.8, group.rate = 1.5)
Print an ibist Confidence Interval Object
## S3 method for class 'ibist_ci' print(x, digits = getOption("digits"), ...)## S3 method for class 'ibist_ci' print(x, digits = getOption("digits"), ...)
x |
An object of class |
digits |
Number of significant digits to print. |
... |
Reserved for future extensions. |
Computes confidence intervals for the difference of two paired proportions.
prop.paired.ci( b, c, n, conf.level = 0.95, method = c("score", "wald", "waldcc", "agresti-min", "wang"), ... )prop.paired.ci( b, c, n, conf.level = 0.95, method = c("score", "wald", "waldcc", "agresti-min", "wang"), ... )
b |
Number of discordant pairs favorable to group 1. |
c |
Number of discordant pairs favorable to group 2. |
n |
Total number of matched pairs. |
conf.level |
Confidence level for the interval. |
method |
Method or methods for confidence interval. One or more of
|
... |
Additional arguments for the selected method. For
|
For a matched-pair table with discordant counts and , the
estimated paired difference is . The "wald" and
"waldcc" methods use the paired Wald standard error, with
"waldcc" adding the continuity-correction term . The
"agresti-min" method applies the Wald calculation to
, , and . The "score" method
inverts Tango's score statistic by numerically maximizing the multinomial
likelihood subject to the candidate difference. The "wang" method
computes Wang's exact interval based on an inductive ordering of the paired
sample space. This method can be time-consuming when the sample size is
moderate because it searches over nuisance parameters and refines the
confidence limits numerically.
An object of class "ibist_ci" containing the common estimate
and a confidence-limit matrix with one row per method.
For method = "score", tol is the numerical tolerance used
when solving for the confidence limits; its default is 1e-8. For
method = "wang", precision controls the numerical precision
of the confidence limits (default 1e-5), while grid.one and
grid.two control the sizes of the two nuisance-parameter search
grids (defaults 30 and 20, respectively). Increasing these
values can improve numerical accuracy at the cost of longer computation.
Tango, T. (1998). Equivalence test and confidence interval for the difference in proportions for the paired-sample design. Statistics in Medicine, 17, 891–908.
Agresti, A., and Min, Y. (2005). Simple improved confidence intervals for comparing matched proportions. Statistics in Medicine, 24, 729–740.
Wang, W. (2012). An inductive order construction for the difference of two dependent proportions. Statistics & Probability Letters, 82, 1623–1628.
prop.paired.ci(b = 8, c = 25, n = 180) prop.paired.ci(b = 8, c = 25, n = 180, method = "waldcc") prop.paired.ci(b = 8, c = 25, n = 180, method = "agresti-min") prop.paired.ci(b = 3, c = 0, n = 4, method = "wang", precision = 0.0001)prop.paired.ci(b = 8, c = 25, n = 180) prop.paired.ci(b = 8, c = 25, n = 180, method = "waldcc") prop.paired.ci(b = 8, c = 25, n = 180, method = "agresti-min") prop.paired.ci(b = 3, c = 0, n = 4, method = "wang", precision = 0.0001)
Computes confidence intervals for a Poisson rate parameter
using several methods.
rate.1s.ci( x, exposure = 1, conf.level = 0.95, method = c("exact", "score", "wh", "wald", "log"), correct = TRUE, ... )rate.1s.ci( x, exposure = 1, conf.level = 0.95, method = c("exact", "score", "wh", "wald", "log"), correct = TRUE, ... )
x |
Non-negative integer. Observed number of events. |
exposure |
Positive numeric. Exposure time (or total time at risk). |
conf.level |
Confidence level. Default is 0.95. |
method |
Method or methods for confidence interval. One or more of:
|
correct |
Logical. Apply continuity correction for
|
... |
Reserved for future extensions. |
This function provides several confidence intervals for the Poisson
rate .
Exact (Garwood): Based on inversion of the Poisson test using chi-square quantiles:
Score: Obtained by inverting the score test. Computed from solving quadratic equations for boundaries.
Wilson-Hilferty: The Wilson–Hilferty (WH) interval is based on a cube-root transformation of a chi-square approximation, which reduces skewness and yields an approximately normal pivot, leading to the cubic form of the limits. The lower limit is
and the upper limit is
Wald:
For ,
For , lower limit 0, upper limit .
Log:
For , applies normal approximation to
and transforms back. For , lower limit 0, upper limit
.
When correct = TRUE, continuity correction is applied on the count
scale for methods that support it.
An object of class "ibist_ci" containing the common estimate
and a confidence-limit matrix with one row per method.
rate.1s.ci(5, 10) rate.1s.ci(5, 10, method = "score") rate.1s.ci(5, 10, method = c("exact", "score", "log")) rate.1s.ci(0, 10, method = "exact")rate.1s.ci(5, 10) rate.1s.ci(5, 10, method = "score") rate.1s.ci(5, 10, method = c("exact", "score", "log")) rate.1s.ci(0, 10, method = "exact")
Computes confidence intervals for the rate ratio
from two independent Poisson counts with
known exposures.
rate.2s.ci( x, exposure = c(1, 1), conf.level = 0.95, method = c("log", "score", "exact"), ... )rate.2s.ci( x, exposure = c(1, 1), conf.level = 0.95, method = c("log", "score", "exact"), ... )
x |
Length-2 vector of non-negative integer event counts. |
exposure |
Length-2 positive numeric vector of exposures. |
conf.level |
Confidence level. Default is 0.95. |
method |
Method or methods for confidence interval. One or more of:
|
... |
Reserved for future extensions. |
For two independent Poisson variables
, the point estimate of the
rate ratio is
The "log" method uses the large-sample interval
and exponentiates the endpoints. This method requires both counts to be positive.
The "score" and "exact" methods use the conditional binomial
representation. Given ,
, where
Confidence limits and for are transformed to
confidence limits for as
The "score" method uses Wilson score limits for ; the
"exact" method uses the exact Clopper-Pearson limits returned by
binom.test.
An object of class "ibist_ci" containing the rate estimates
and a confidence-limit matrix with one row per method.
rate.2s.ci(c(151, 55), exposure = c(57518.1, 74573.5)) rate.2s.ci(c(151, 55), exposure = c(57518.1, 74573.5), method = "score") rate.2s.ci(c(151, 55), exposure = c(57518.1, 74573.5), method = c("log", "score")) rate.2s.ci(c(9, 12), exposure = c(1817.6, 7496.3), method = "exact")rate.2s.ci(c(151, 55), exposure = c(57518.1, 74573.5)) rate.2s.ci(c(151, 55), exposure = c(57518.1, 74573.5), method = "score") rate.2s.ci(c(151, 55), exposure = c(57518.1, 74573.5), method = c("log", "score")) rate.2s.ci(c(9, 12), exposure = c(1817.6, 7496.3), method = "exact")
Performs a large-sample (normal) test for one or two Poisson rates with known exposures. The test is carried out on the observed count scale and then translated to rates for reporting.
rate.test( x, exposure = 1, r = 1, alternative = c("two.sided", "less", "greater"), conf.level = 0.95, correct = TRUE )rate.test( x, exposure = 1, r = 1, alternative = c("two.sided", "less", "greater"), conf.level = 0.95, correct = TRUE )
x |
a vector of event counts. A single value specifies a one-sample test; a vector of length two specifies a two-sample comparison. |
exposure |
a vector of exposures corresponding to |
r |
a positive number specifying the null rate per unit exposure,
|
alternative |
a character string specifying the alternative hypothesis,
one of |
conf.level |
confidence level for the confidence interval. For one-sample tests, the interval is the score confidence interval for the rate. For two-sample tests, the interval is the log-Wald confidence interval for the rate ratio. |
correct |
logical; if |
One-sample test:
Assume with . The null
hypothesis is , where . Let
. The normal approximation gives
where is 0 if correct = FALSE and is a continuity correction on
the count scale if correct = TRUE. Two-sided p-values use
.
Two-sample test:
Assume independent and
with known exposures
and . The null hypothesis is
.
For hypothesis testing, the function uses the exact conditional
representation under :
and applies the same large-sample normal approximation as
prop.test (with optional Yates continuity correction)
to obtain the test statistic and p-value.
For estimation and confidence intervals, the inference target is the
rate ratio,
.
The point estimate is
, and the confidence interval is
constructed on the log scale using estimated standard error
The continuity correction affects the hypothesis test but not the
confidence interval for .
Confidence intervals:
For one-sample tests, the confidence interval is the score interval for
, as computed by rate.1s.ci with
method = "score".
For two-sample tests, the confidence interval is for the rate ratio
. The log-Wald interval requires both event counts
to be positive.
An object of class "htest" containing:
statistic |
the standardized normal statistic |
parameter |
degrees of freedom ( |
p.value |
the p-value. |
conf.int |
a confidence interval for the rate in one-sample tests or
for the rate ratio, |
estimate |
estimated rate (one-sample) or estimated rates and rate ratio (two-sample). |
null.value |
the null rate (one-sample) or the null rate ratio
|
alternative |
the alternative hypothesis. |
method |
a character string describing the test. |
data.name |
a character string describing the data. |
rate.2s.ci, prop.test,
poisson.test
## One-sample test: compare observed rate to a reference unit rate rate.test(x = 411, exposure = 25800, r = 0.0119) rate.test(x = 411, exposure = 25800, r = 0.0119, correct = FALSE) ## Two-sample test: compare two Poisson rates rate.test(x = c(12, 5), exposure = c(100, 80)) rate.test(x = c(12, 5), exposure = c(100, 80), correct = FALSE) ## One-sided alternative rate.test(x = 411, exposure = 25800, r = 0.0119, alternative = "greater")## One-sample test: compare observed rate to a reference unit rate rate.test(x = 411, exposure = 25800, r = 0.0119) rate.test(x = 411, exposure = 25800, r = 0.0119, correct = FALSE) ## Two-sample test: compare two Poisson rates rate.test(x = c(12, 5), exposure = c(100, 80)) rate.test(x = c(12, 5), exposure = c(100, 80), correct = FALSE) ## One-sided alternative rate.test(x = 411, exposure = 25800, r = 0.0119, alternative = "greater")
Aggregated counts of neonatal outcomes by birth weight, surfactant use, and survival status.
rdsrds
A data frame with 16 rows and 4 variables:
Birth weight category in grams (factor with 4 levels).
Surfactant use (Yes/No).
Outcome (1 = death; 0 = alive).
Number of infants in each group.
The data are presented in aggregated form. Each row corresponds
to a combination of birth weight category, surfactant use, and
outcome, with count indicating the number of observations.
Analyses should account for the grouped structure, e.g., via weighted models or binomial responses.
Classical neonatal RDS dataset (exact source to be specified).