Skip to contents

This function calculates the Z-statistic for the Cochran-Armitage trend test using adjusted counts and sample sizes.

Usage

get_CA_Z(adj_x, adj_n)

Arguments

adj_x

Vector of adjusted affected counts for each treatment group

adj_n

Vector of adjusted sample sizes for each treatment group

Value

The Z-statistic for the Cochran-Armitage trend test

Details

The Cochran-Armitage trend test examines whether there is a linear trend in proportions across ordered categories (treatment groups). This implementation uses adjusted values to account for clustering in the data.

The function assigns scores (1, 2, 3, ...) to the treatment groups and calculates the Z-statistic using the formula: \deqn{Z = [sum(adj_x*d) - N*p_bar*d_bar] / sqrt[p_bar*(1-p_bar)*(sum(adj_n*d^2) - N*d_bar^2)] where:

  • d are the scores (1, 2, 3, ...)

  • N is the total adjusted sample size

  • d_bar is the weighted average of scores

  • p_bar is the overall proportion of affected subjects

Author

Originally by Allen Olmstead

Examples

# Get adjusted values
data(dat_bcs1)
adj_vals <- get_RS_adj_val(
  dat_bcs1$tmt,
  dat_bcs1$tank,
  dat_bcs1$S1 + dat_bcs1$S2 + dat_bcs1$S3,
  dat_bcs1$total
)
# Calculate Z-statistic
Z <- get_CA_Z(adj_vals$x_tilde, adj_vals$n_tilde)