Skip to contents

This function performs Cochran's Q Test, a non-parametric test for examining differences in proportions across multiple related groups. It is based on the `RVAideMemoire` package's implementation, adapted here to avoid external dependencies and ensure seamless integration. Cochran's Q Test is commonly used in repeated measures designs or studies with binary response data.

Usage

calc_cochran_qtest(formula, data, alpha = 0.05, p.method = "bonferroni")

Arguments

formula

A formula specifying the model to use in the test. Typically, the format is `value ~ name | referent`, where `value` is the binary response variable and `name` represents different conditions or responses.

data

A `data.frame` containing the binary responses for each verbal operant (e.g., `Conversing`, `Labeling`, `Echoing`, and `Requesting`). The data should be transformed with `pivot_longer` so that the binary operant names are in a `name` column, and responses are in a `value` column.

alpha

Significance level for the test (e.g., 0.05).

p.method

Method for p-value adjustment for multiple comparisons; VOX analysis uses `bonferroni`.

Value

A `list` containing the following components:

statistic

The test statistic for Cochran's Q.

p.value

The p-value associated with the test statistic, after adjustment if `p.method` is specified.

...

Other values are returned, but not used for the purpose of the VOX Analysis app.

Examples

# Example of Cochran's Q Test using sample response data
library(dplyr)
library(tidyr)
data("df_input_response_example")
 dat <- df_input_response_example %>%
    select("referent", "conversing", "labeling", "echoing", "requesting") %>%
   pivot_longer(
     cols = c("conversing", "labeling", "echoing", "requesting"),
     names_to = "name",
     values_to = "value") %>%
     arrange(.data$name)
calc_cochran_qtest(
  formula = value ~ name | referent,
  data = dat,
  alpha = 0.05,
  p.method = "bonferroni"
)
#> $method.test
#> [1] "Cochran's Q test"
#> 
#> $data.name
#> [1] "value by name, block = referent"
#> 
#> $statistic
#>   Q 
#> 7.5 
#> 
#> $parameter
#> df 
#>  3 
#> 
#> $alternative
#> [1] "two.sided"
#> 
#> $null.value
#> difference in probabilities 
#>                           0 
#> 
#> $p.value
#> [1] 0.05755845
#> 
#> $estimate
#> proba in group             <NA>            <NA>            <NA> 
#>       0.1666667       0.8333333       0.6666667       0.3333333 
#> 
#> $alpha
#> [1] 0.05
#> 
#> attr(,"class")
#> [1] "RVtest"