Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

prop_trend_test

Test for Trend in Proportions


Description

Performs chi-squared test for trend in proportion. This test is also known as Cochran-Armitage trend test.

Wrappers around the R base function prop.trend.test() but returns a data frame for easy data visualization.

Usage

prop_trend_test(xtab, score = NULL)

Arguments

xtab

a cross-tabulation (or contingency table) with two columns and multiple rows (rx2 design). The columns give the counts of successes and failures respectively.

score

group score. If NULL, the default is group number.

Value

return a data frame with some the following columns:

  • n: the number of participants.

  • statistic: the value of Chi-squared trend test statistic.

  • df: the degrees of freedom.

  • p: p-value.

  • method: the used statistical test.

  • p.signif: the significance level of p-values and adjusted p-values, respectively.

The returned object has an attribute called args, which is a list holding the test arguments.

Examples

# Proportion of renal stone (calculi) across age
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# Data
xtab <- as.table(rbind(
  c(384, 536, 335),
  c(951, 869, 438)
))
dimnames(xtab) <- list(
  stone = c("yes", "no"),
  age = c("30-39", "40-49", "50-59")
)
xtab
# Compare the proportion of survived between groups
prop_trend_test(xtab)

rstatix

Pipe-Friendly Framework for Basic Statistical Tests

v0.7.0
GPL-2
Authors
Alboukadel Kassambara [aut, cre]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.