pairwise_comparison computes pairwise Tukey comparisons for any combination of variables in a given QGAM using the emmeans package. Pairwise Tukey comparisons are most sensible to check differences between levels of a categorical predictor.

pairwise_comparison(
  qgam,
  quantile = NULL,
  factor, by = NULL,
  ...)

Arguments

qgam

A qgam object created with qgam::qgam or extracted from a qgam::mqgam object, or a collection of qgams created with qgam::mqgam.

quantile

If qgam is a collection of qgam models, specify the quantile you are interested in. Not meaningful for single qgam objects.

factor

The categorical variable you wish to compute Tukey comparisons for. Must be one of the predictor or smooth terms given in the qgam formula.

...

Any of the other arguments emmeans::emmeans can take.

References

Russell V. Lenth (2021). emmeans: Estimated Marginal Means, aka Least-Squares Means. R package version 1.5.4. https://CRAN.R-project.org/package=emmeans

Author

D. Schmitz

Examples


pairwise_comparison(qgam = mtqgam_mqgam, quantile = 0.5, "factor_1")
#>  contrast estimate   SE   df t.ratio p.value
#>  J - K        0.12 1.54 4984  0.078  0.9998 
#>  J - L       -3.52 6.81 4984 -0.517  0.9550 
#>  J - M       -1.01 1.62 4984 -0.620  0.9257 
#>  K - L       -3.64 6.67 4984 -0.545  0.9478 
#>  K - M       -1.13 0.92 4984 -1.225  0.6110 
#>  L - M        2.51 6.69 4984  0.376  0.9819 
#> 
#> Results are averaged over the levels of: factor_2, factor_3 
#> P value adjustment: tukey method for comparing a family of 4 estimates