test: Test differences within temporal slices

testR Documentation

Test differences within temporal slices

Description

Useful after fitting to test "synchronic" differences between groups. Within a temporal unit :

Usage

test_globally(df, x = x_pred, y = y_pred, by = group, test_fun = kruskal_p)

test_pairwise(df, x = x_pred, y = y_pred, by = group, test_fun = wilcox_p)

Arguments

df

tibble() typically the result of quake()

x, y, group

colnames to use. Default to x_pred/y_pred

by

colname for the group to use. Default to group

test_fun

function to pick among comparison_testers(comparison testers). By default kruskal_p/wilcox_p for synchrony/synchrony_pw, respectively.

Details

  • test_globally will test if at least one group differs from the others

  • test_pairwise will test all pairwise differences between groups present at that time.

Functions

  • test_globally: test for global differences

  • test_pairwise: test for pairwise differences

Examples


# for the sake of speed
x <- animals %>%
  quake(5, min=tpq, max=taq) %>%
  fit_gam(y=value, by=taxa, x_pred=seq(-100, 100, 50))

x %>% spaghetti(by=taxa)

# global testing
x %>% test_globally(by=taxa)

# pairwise testing
x %>% test_pairwise(by=taxa)

# you can filter "significant" ones
alpha=0.01
x %>%
  test_pairwise(by=taxa) %>%
  dplyr::mutate(signif=p<alpha)
  # you can continue the pipe with
  # dplyr::filter(!signif) to only get not different
  # or
  # dplyr::filter(signif) to only the different ones

# yet before, you probably need to adjust your alpha
# by the number of tests, ie do some Bonferroni correction
# the number of tests is simply dplyr::n()

x %>%
  test_pairwise(by=taxa) %>%
  dplyr::mutate(alpha_adj=alpha/dplyr::n(),
                signif=p<alpha_adj)


vbonhomme/pataqu documentation built on April 24, 2022, 10:03 p.m.