View source: R/srh.simple.posthoc.R
srh.simple.posthoc | R Documentation |
Computes Dunn's pairwise comparisons for simple effects of one target
factor (compare
) within levels of the remaining conditioning factors
(by
). Adjustment can be done within each conditioning table
(SPSS-like) or globally across all tests.
srh.simple.posthoc(
formula,
data,
compare = NULL,
scope = c("within", "global"),
digits = 3
)
formula |
A formula of the form |
data |
A |
compare |
Character; the factor to compare pairwise. By default, the
first factor on the RHS of |
scope |
|
digits |
Number of digits for rounding numeric columns ( |
The data are subset to complete cases on y
and all RHS factors.
All RHS variables are coerced to factor
. The table is split by all
factors except compare
and Dunn's test (FSA::dunnTest
) is run
per split. With scope = "within"
, the Bonferroni correction is applied
separately in each split (with m.tests = choose(k,2)
for that split).
With scope = "global"
, P.adj
is re-computed once with
stats::p.adjust(..., method = "bonferroni")
across all pairwise
tests from all splits (and m.tests
is set to the total number of
tests).
A data.frame
with columns:
conditioning factor columns (one value repeated per split),
Comparison
, Z
, P.unadj
, P.adj
,
m.tests
(number of tests used for Bonferroni),
adj.note
(human-readable note).
Attributes: "adjustment"
(one-line description) and "call"
.
data(mimicry, package = "factorH")
# Two factors: pairwise comparisons for 'gender' within levels of 'condition'.
# By default, compare = first RHS factor ('gender' here).
# p.adj uses Bonferroni within each by-table (scope = "within").
tab1 <- srh.simple.posthoc(liking ~ gender + condition, data = mimicry)
head(tab1); attr(tab1, "adjustment")
# One global family of tests (global Bonferroni across all subgroup tests):
tab2 <- srh.simple.posthoc(liking ~ gender + condition, data = mimicry,
scope = "global")
head(tab2); attr(tab2, "adjustment")
# Three factors: compare 'gender' within each condition × age_cat cell.
tab3 <- srh.simple.posthoc(liking ~ gender + condition + age_cat, data = mimicry)
head(tab3)
# Choose a different target factor to compare: here 'condition'
# (within each gender × age_cat cell).
tabA <- srh.simple.posthoc(liking ~ gender + condition + age_cat, data = mimicry,
compare = "condition")
head(tabA)
# Global Bonferroni variants (less common, but sometimes requested):
tabG <- srh.simple.posthoc(liking ~ gender + condition + age_cat, data = mimicry,
scope = "global")
tabG2 <- srh.simple.posthoc(liking ~ condition + gender, data = mimicry)
tabG3 <- srh.simple.posthoc(liking ~ condition + gender, data = mimicry,
scope = "global")
head(tabG); head(tabG2); head(tabG3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.