This function is a wrapper that performs the Rao-Scott adjusted Cochran-Armitage trend test for clustered binary data.
Arguments
- group
Vector of treatment group identifiers
- replicate
Vector of replicate/tank identifiers within treatment groups
- affected
Vector of counts of affected subjects (fish with injuries) in each replicate
- total
Vector of total subjects (fish) in each replicate
- correction
continuity correction when there is 1, default is 0, can be changed to 0.5.
Value
A list containing:
- interm_values
A tibble with intermediate values from the Rao-Scott adjustment
- Z
The Z-statistic for the Cochran-Armitage trend test
Details
This function combines the Rao-Scott adjustment and the Cochran-Armitage trend test to analyze dose-response relationships in clustered data. It first calculates adjusted values accounting for clustering, then uses these values to perform the trend test.
The p-value can be calculated using: 2 * (1 - pnorm(abs(Z)))
Examples
# Test for trend in injury rates across treatment groups
# Considering S1, S2, and S3 as "affected"
result <- run_RSCA(
dat_bcs1$tmt,
dat_bcs1$tank,
dat_bcs1$S1 + dat_bcs1$S2 + dat_bcs1$S3,
dat_bcs1$total
)
# View intermediate values
print(result$interm_values)
#> # A tibble: 5 × 10
#> grp x n m p_hat b v D n_tilde x_tilde
#> <chr> <dbl> <dbl> <int> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 C 6 16 4 0.375 0.0146 0.00521 1 16 6
#> 2 SC 10 16 4 0.625 0.0146 0.0156 1.07 15 9.38
#> 3 T1 3 16 4 0.188 0.00952 0.0143 1.50 10.6 1.99
#> 4 T2 7 16 4 0.438 0.0154 0.0143 1 16 7
#> 5 T3 8 16 4 0.5 0.0156 0.0312 2 8 4
# View Z-statistic
print(result$Z)
#> [1] 0.01966517
# Calculate p-value
p_value <- 2 * (1 - pnorm(abs(result$Z)))
print(paste("p-value:", p_value))
#> [1] "p-value: 0.984310478271696"