Runs all k(k-1)/2 pairwise two-sample t-tests for a grouping variable
with k levels and applies multiple-comparison p-value adjustment.
Delegates pair-level computations to get_t_test().
get_pairwise(
design,
x,
by,
group = NULL,
pval_adj = "holm",
conf_level = 0.95,
variance = "ci",
na.rm = TRUE,
min_cell_n = 30L,
decimals = NULL,
label_values = TRUE,
label_vars = TRUE,
name_style = "surveycore",
...,
.id = NULL,
.if_missing_var = NULL
)A survey_pairwise tibble (also inheriting survey_result).
Columns: group columns (when active), level_a, level_b,
estimate, mean_a, mean_b, n_a, n_b, se (optional),
ci_low (optional), ci_high (optional), t_stat, df,
p_value (adjusted), stars. Use meta() to access the
adjustment method and other metadata.
A survey design object: survey_taylor,
survey_replicate, survey_twophase, or survey_nonprob.
<tidy-select> A single unquoted
numeric variable name for the outcome variable.
<tidy-select> A single unquoted
variable name for the grouping variable. Must have at least 2 active
levels.
<tidy-select> Optional subgroup
variable(s). When supplied, pairwise comparisons are run within each
group stratum. P-value adjustment is applied separately per stratum.
Default NULL.
Character(1). P-value adjustment method passed to
stats::p.adjust(). Default "holm". Use "none" for unadjusted
p-values. Error: surveycore_error_invalid_pval_adj.
Numeric(1). Confidence level strictly in (0, 1).
Default 0.95.
Character. Which uncertainty columns to include.
Valid values: "se", "ci". Default "ci".
Logical(1). Accepted for API uniformity. Default TRUE.
Integer(1). Warn for small cells. Default 30L.
Integer(1) or NULL. Round all double output columns.
Default NULL.
Logical(1). Convert by/group codes to value
labels. Default TRUE.
Logical(1). Accepted for API uniformity; no visible
effect. Default TRUE.
Character(1). "surveycore" (default) or "broom".
Unused. Reserved so that .id and .if_missing_var remain
named-only when a survey_collection is passed as design.
Character(1) or NULL. Column name used to identify each
survey when design is a survey_collection. For collection inputs,
NULL (the default) resolves to the collection's stored @id property.
Pass a non-NULL value to override. Ignored when design is a single
survey.
"error", "skip", or NULL. How to handle
surveys in a collection that lack one of the requested NSE variables.
For collection inputs, NULL (the default) resolves to the collection's
stored @if_missing_var property. Pass a non-NULL value to override.
Ignored when design is a single survey.
Other analysis:
clean(),
get_anova(),
get_corr(),
get_covariance(),
get_diffs(),
get_freqs(),
get_means(),
get_quantiles(),
get_ratios(),
get_t_test(),
get_totals(),
get_variance(),
meta()
gss_sub <- gss_2024[gss_2024$sex %in% c(1L, 2L) & !is.na(gss_2024$age), ]
gss_sub$sex <- factor(gss_sub$sex, levels = c(1, 2), labels = c("Male", "Female"))
gss_design <- as_survey(gss_sub,
ids = vpsu, weights = wtssps, strata = vstrat, nest = TRUE)
get_pairwise(gss_design, age, by = sex)
Run the code above in your browser using DataLab