pairComp: Pairwise comparisons between the elements of a vector

View source: R/pairComp.R

pairCompR Documentation

Pairwise comparisons between the elements of a vector

Description

This function provides pairwise comparisons between the element of a vector, as long as a variance-covariance matrix is also provided

Usage

pairComp(parm, vcovMat, nams = NULL, dfr = NULL, adjust = "none",
         level = 0.05, Letters = c(letters, LETTERS, "."), 
         reversed = FALSE)

Arguments

parm

A (possibly named) vector of estimates

vcovMat

Variance-covariance matrix for the estimates

nams

A character vector of parameter names (optional). If it is not provided and if 'parm' is not a named vectors, numbers '1:length(parm)' are used.

dfr

An optional number of residual degrees of freedom (defaults to Inf)

adjust

A multiplicity adjustment method as in 'multcomp'. Defaults to "none".

level

Protection level for compact letter display

Letters

Vector of distinct characters (or character strings) used to connect levels that are not significantly different. They should be recogizable when concatenated. The default behaviour is to use the small letters, followed by the capital letters. See help for 'multcompView::multcompLetters()' for futher detail)

reversed

logical. Should the order of means/letters be decreasing? Defaults to FALSE, which means that the means and letters are in increasing order)

Value

Returns a list with the following elements

Pairs

A dataframe of pairwise comparisons

Letters

A dataframe with compact letter display

Author(s)

Andrea Onofri

References

Onofri A. (2020) The broken bridge between biologists and statisticians: a blog and R package, Statforbiology, IT, web: https://www.statforbiology.com

Examples

# library(devtools)
# install_github("OnofriAndreaPG/aomisc")
library(aomisc)
data(metamitron)

#Fit nls grouped model
modNlin <- nls(Conc ~ A[Herbicide] * exp(-k[Herbicide] * Time), 
               start=list(A=rep(100, 4), k=rep(0.06, 4)), 
               data=metamitron)
tab <- summary(modNlin)
tab

# Retreive infos and make comparisons
coefs <- coef(modNlin)[5:8] 
vcovMat <- vcov(modNlin)[5:8, 5:8]
cp <- pairComp(coefs, vcovMat, dfr = tab$df[2], 
               adjust = "none", reversed = FALSE)
cp$Letters
cp$pairs

OnofriAndreaPG/aomisc documentation built on Feb. 26, 2024, 8:21 p.m.