comparisons {cg} | R Documentation |
Create a table of comparisons amongst groups
Description
Create a table of comparisons based on group estimates and variance-covariance matrix. Pairwise or custom specified contrasts are estimated and tested.
Usage
comparisons(estimates, varcovmatrix, errordf = Inf, endptscale,
mcadjust = FALSE, alpha = 0.05, type = "pairwisereflect",
contrastmatrix = NULL, n, offset = NULL, cnames = "derive",
analysisname = "", endptname = "", digits = NULL, addpct = FALSE,
display = "print")
Arguments
estimates |
A named vector of estimates. Each estimate element is a measure of the center of the group. The name of each group must be present in the names attribute of the vector. |
varcovmatrix |
The estimated variance-covariance matrix associated with the
|
errordf |
Can be one of three types of values:
|
endptscale |
Must be specified as |
mcadjust |
Do a multiple comparisons adjustment, based on the simultaneous
inference capabilities of the multcomp package. See Details
below. The default value is |
alpha |
Significance level, by default set to |
type |
Can be one of four values:
|
contrastmatrix |
Only relevant if |
n |
Needs to be specified only when
|
offset |
Optional,
If for example a numeric constant was added to all response values
before calculation of the |
cnames |
If the default value of |
analysisname |
Optional, a character text that will be
printed along with the results table. The default
value is the empty |
endptname |
Optional, a character text that will be
printed along with the results table. The default
value is the empty |
digits |
Optional, For output display purposes,
values will be rounded to this numeric
value. Only the integers of 0, 1, 2, 3, and 4 are accepted. No
rounding is done during any calculations. The default value is
|
addpct |
Only relevant if |
display |
One of three valid values:
|
Details
Only two-sided Wald-type of confidence intervals are possible with this function.
When mcadjust=TRUE
, a status message of
"Some time may be needed as the critical point "
"from the multcomp::summary.glht function call is calculated "
is displayed at the console. This computed critical point
is used for all subsequent p-value and confidence interval
calculations.
The multcomp package provides a unified way to calculate critical points based on the comparisons of interest in a "family." Thus a user does not need to worry about choosing amongst the myriad names of multiple comparison procedures.
Value
Creates a return data frame object that specifies the comparison of the form A vs. B in each row, and with these columns:
estimate
The difference in group estimates in the comparison: A vs. B. If
endptscale="log"
, this will be back-transformed to a percent difference scale.se
The estimated standard error of the difference
estimate
. Ifendptscale="log"
, this estimate will be based on the Delta method, and will particularly begin to be a poor approximation when the standard error in the logscale exceeds 0.50.lowerci
The lower 100 * (1-
alpha
) % confidence limit of the differenceestimate
. With the defaultalpha=0.05
, this is 95%. Ifendptscale="log"
, the confidence limit is first computed in the logarithmic scale of analysis, and then back-transformed to a percent difference scale.upperci
The upper 100 * (1-
alpha
) % confidence limit of the differenceestimate
. With the defaultalpha=0.05
, this is 95%. Ifendptscale="log"
, the confidence limit is first computed in the logarithmic scale of analysis, and then back-transformed to a percent difference scale.pval
The computed p-value from the test of the difference
estimate
.meanA
orgeomeanA
The estimated "mean" for the left hand side "A" of the A vs. B comparison. If
endptscale="log"
, this is a back-transform to the original scale, and therefore is a "geometric" mean, and will be labelledgeomeanA
. Otherwise it is the arithmetic mean and labelledmeanA
.seA
The estimated standard error of the
meanA
estimate
. Ifendptscale="log"
, this estimate will be based on the Delta method, and will particularly begin to be a poor approximation when the standard error in the logscale exceeds 0.50.meanB
orgeomeanB
The estimated "mean" for the right hand side "B" of the A vs. B comparison. If
endptscale="log"
, this is a back-transform to the original scale, and therefore is a "geometric" mean, and will be labelledgeomeanB
. Otherwise it is the arithmetic mean and labelledmeanB
.seB
The estimated standard error of the
meanB
estimate
. Ifendptscale="log"
, this estimate will be based on the Delta method, and will particularly begin to be a poor approximation when the standard error in the logscale exceeds 0.50.
An additional column addpct
of percent differences is added if
endptscale=="original"
and addpct=TRUE
,
as a descriptive supplement to the original scale
differences that are formally estimated.
Warning
This function was created for internal use in the cg package as
its use can be seen in the comparisonsTable
methods
code. Therefore any direct use of it needs to be done cautiously.
Note
Contact cg@billpikounis.net for bug reports, questions, concerns, and comments.
Author(s)
Bill Pikounis [aut, cre, cph], John Oleynick [aut], Eva Ye [ctb]
References
Hothorn, T., Bretz, F., Westfall, P., Heiberger, R.M., and Schuetzenmeister, A. (2010). The multcomp package.
Hothorn, T., Bretz, F., and Westfall, P. (2008). "Simultaneous Inference in General Parametric Models", Biometrical Journal, 50, 3, 346-363.
Examples
data(canine)
canine.data <- prepareCGOneFactorData(canine, format="groupcolumns",
analysisname="Canine",
endptname="Prostate Volume",
endptunits=expression(plain(cm)^3),
digits=1, logscale=TRUE, refgrp="CC")
canine.fit <- fit(canine.data)
## Easier way: notice the comparisonsTable call
comparisonsTable(canine.fit, model="olsonly")
## Manual way
## Instead of comparisonsTable(canine.fit, model="olsonly")
comparisons(estimates=canine.fit@olsfit$coef,
varcovmatrix=vcov(canine.fit@olsfit),
errordf=canine.fit@olsfit$df.residual,
endptscale="log",
analysisname="Canine",
digits=1,
endptname="Prostate Volume")