comparisonsgraph: Create an graph of comparisons

Description Usage Arguments Details Value Warning Note Author(s) See Also Examples

View source: R/p03FormalOneFactorData.R

Description

Creates a graph to see comparisons based on group estimates and variance-covariance matrix

Usage

1
2
3
4
5
comparisonsgraph(compstable, difftype, analysisname = "",
                 endptname = "", alpha = 0.05, digits = NULL,
                 titlestamp = TRUE, explanation = TRUE,
                 wraplength = 20, cex.comps = 0.7,
                 ticklabels = NULL, ...) 

Arguments

compstable

A data frame object of form like that created by the comparisons function.

difftype

Must be specified as one of the following:

"percent"

Presumes the estimated differences in compstable are Percent, and thus will space the x-axis logarithmically;

"amount"

Presumes the estimated differences in compstable are Simple Amounts, and thus will space the x-axis in untransformed scale;

"simple"

Synonym for amount, presumes the estimated differences in compstable are Simple Amounts, and thus will space the x-axis in untransformed scale.

analysisname

Optional, a character text or math-valid expression that will used in the graph title. The default value is the empty "".

endptname

Optional, a character text or math-valid expression that that will be used as the x-axis label of the graph. The default value is the empty "".

alpha

Significance level, by default set to 0.05. This is only used for labelling purposes.

digits

Optional, For output display purposes in the graph, 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 NULL, which will examine each individual data value and choose the one that has the maximum number of digits after any trailing zeroes are ignored. The max number of digits will be 4.

explanation

If TRUE, which is the default, add explanatory message to the graph rendering about "Error bars that do not cross the zero line indicate statistically significant difference(s)" along with the confidence level derived from alpha.

titlestamp

Specify text to the graph in the top of graph area, otherwise a default description of "Comparisons Graph" and analysisname will be constructed.

wraplength

On the left hand axis are each A vs. B comparison label from the compstable data frame. An attempt at sensible formatting when a newline is needed is made, but adjustment by this argument may be needed. The default is 20 characters before wrapping to a newline.

cex.comps

Similar to wraplength, adjustment of this argument parameter can be made to fit the comparison labels on the left hand axis.

ticklabels

Optional, before graphing the data, remove any automatically generated tickmarks for the x-axis, and use these tickmarks instead. A vector of tickmarks to be placed on the x-axis. Any numeric representations will be coerced to character.

...

Additional arguments. None are currently used.

Details

The minimum and maximum values across all the bar ends are added inside the plot region in blue, flush against the x-axis. In two panel cases, there is a tendency to fall outside the panel area even though right justified is used for the adj parameter of functions like panel.text.

Value

comparisonsgraph returns an invisible NULL. The main purpose is the side effect of graphing to the current device.

Warning

This function was created for internal use in the cg package as its use can be seen in the comparisonsGraph methods source 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]

See Also

comparisons

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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)
canine.comps <- comparisonsTable(canine.fit)

## Easier way: notice the camel-case of the comparisonsGraph call

comparisonsGraph(canine.comps, model="olsonly")

## Manual way
## Instead of comparisonsGraph(canine.comps, model="olsonly")

canine.compstable <- 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")

comparisonsgraph(canine.compstable,
                 difftype="percent",
                 analysisname="Canine",
                 digits=1,
                 endptname=expression(paste( plain('Prostate Volume'),
                                      ' (', plain(cm)^3  ,  ')' ))  
                ) 

Example output

Loading required package: Hmisc
Loading required package: lattice
Loading required package: survival
Loading required package: Formula
Loading required package: ggplot2

Attaching package:HmiscThe following objects are masked frompackage:base:

    format.pval, units

Comparisons Table of Canine 
Endpoint: Prostate Volume 
Percent Differences (A vs. B) 

Classical Least Squares Model Fit
95% Confidence (alpha of 0.05)
          estimate  se lowerci upperci   pval geomeanA seA geomeanB seB
E1 vs. AE      -15  23     -52      49  0.544     12.3 2.4     14.5 2.8
E2 vs. AE       60  43    -9.5     182  0.101     23.2 4.5     14.5 2.8
CC vs. AE      -74 7.0     -86     -55 <0.001      3.7 0.7     14.5 2.8
NC vs. AE     -2.0  27     -44      73  0.942     14.2 2.7     14.5 2.8
AE vs. E1       18  32     -33     109  0.544     14.5 2.8     12.3 2.4
E2 vs. E1       89  51     7.0     233  0.030     23.2 4.5     12.3 2.4
CC vs. E1      -70 8.2     -83     -47 <0.001      3.7 0.7     12.3 2.4
NC vs. E1       16  32     -34     105  0.593     14.2 2.7     12.3 2.4
AE vs. E2      -37  17     -64      11  0.101     14.5 2.8     23.2 4.5
E1 vs. E2      -47  14     -70    -6.6  0.030     12.3 2.4     23.2 4.5
CC vs. E2      -84 4.4     -91     -72 <0.001      3.7 0.7     23.2 4.5
NC vs. E2      -39  17     -65     8.3  0.088     14.2 2.7     23.2 4.5
AE vs. CC      291 106     122     590 <0.001     14.5 2.8      3.7 0.7
E1 vs. CC      231  90      87     483 <0.001     12.3 2.4      3.7 0.7
E2 vs. CC      524 170     254    1001 <0.001     23.2 4.5      3.7 0.7
NC vs. CC      283 104     117     576 <0.001     14.2 2.7      3.7 0.7
AE vs. NC      2.0  28     -42      80  0.942     14.5 2.8     14.2 2.7
E1 vs. NC      -14  23     -51      52  0.593     12.3 2.4     14.2 2.7
E2 vs. NC       63  44    -7.7     187  0.088     23.2 4.5     14.2 2.7
CC vs. NC      -74 7.1     -85     -54 <0.001      3.7 0.7     14.2 2.7

Resistant & Robust Model Fit
95% Confidence (alpha of 0.05)
          estimate  se lowerci upperci   pval geomeanA seA geomeanB seB
E1 vs. AE      -15  25     -53      55  0.584     12.4 2.5     14.5 3.0
E2 vs. AE       60  46     -12     193  0.119     23.2 4.8     14.5 3.0
CC vs. AE      -74 7.4     -86     -53 <0.001      3.7 0.8     14.5 3.0
NC vs. AE     -2.6  28     -47      77  0.927     14.1 2.9     14.5 3.0
AE vs. E1       17  34     -36     114  0.584     14.5 3.0     12.4 2.5
E2 vs. E1       88  54     2.8     244  0.041     23.2 4.8     12.4 2.5
CC vs. E1      -70 8.7     -83     -45  0.001      3.7 0.8     12.4 2.5
NC vs. E1       14  33     -37     108  0.647     14.1 2.9     12.4 2.5
AE vs. E2      -38  18     -66      14  0.119     14.5 3.0     23.2 4.8
E1 vs. E2      -47  15     -71    -2.7  0.041     12.4 2.5     23.2 4.8
CC vs. E2      -84 4.7     -91     -71 <0.001      3.7 0.8     23.2 4.8
NC vs. E2      -39  18     -67      11  0.099     14.1 2.9     23.2 4.8
AE vs. CC      288 112     113     607 <0.001     14.5 3.0      3.7 0.8
E1 vs. CC      230  95      81     503  0.001     12.4 2.5      3.7 0.8
E2 vs. CC      521 180     240    1035 <0.001     23.2 4.8      3.7 0.8
NC vs. CC      278 108     107     587 <0.001     14.1 2.9      3.7 0.8
AE vs. NC      2.7  29     -44      87  0.927     14.5 3.0     14.1 2.9
E1 vs. NC      -13  25     -52      59  0.647     12.4 2.5     14.1 2.9
E2 vs. NC       65  47    -9.8     200  0.099     23.2 4.8     14.1 2.9
CC vs. NC      -74 7.6     -85     -52 <0.001      3.7 0.8     14.1 2.9
Comparisons Table for Canine 
Endpoint: Prostate Volume 
Percent Differences (A vs. B) 
95% Confidence (alpha of 0.05)
          estimate  se lowerci upperci   pval geomeanA seA geomeanB seB
E1 vs. AE      -15  23     -52      49  0.544     12.3 2.4     14.5 2.8
E2 vs. AE       60  43    -9.5     182  0.101     23.2 4.5     14.5 2.8
CC vs. AE      -74 7.0     -86     -55 <0.001      3.7 0.7     14.5 2.8
NC vs. AE     -2.0  27     -44      73  0.942     14.2 2.7     14.5 2.8
AE vs. E1       18  32     -33     109  0.544     14.5 2.8     12.3 2.4
E2 vs. E1       89  51     7.0     233  0.030     23.2 4.5     12.3 2.4
CC vs. E1      -70 8.2     -83     -47 <0.001      3.7 0.7     12.3 2.4
NC vs. E1       16  32     -34     105  0.593     14.2 2.7     12.3 2.4
AE vs. E2      -37  17     -64      11  0.101     14.5 2.8     23.2 4.5
E1 vs. E2      -47  14     -70    -6.6  0.030     12.3 2.4     23.2 4.5
CC vs. E2      -84 4.4     -91     -72 <0.001      3.7 0.7     23.2 4.5
NC vs. E2      -39  17     -65     8.3  0.088     14.2 2.7     23.2 4.5
AE vs. CC      291 106     122     590 <0.001     14.5 2.8      3.7 0.7
E1 vs. CC      231  90      87     483 <0.001     12.3 2.4      3.7 0.7
E2 vs. CC      524 170     254    1001 <0.001     23.2 4.5      3.7 0.7
NC vs. CC      283 104     117     576 <0.001     14.2 2.7      3.7 0.7
AE vs. NC      2.0  28     -42      80  0.942     14.5 2.8     14.2 2.7
E1 vs. NC      -14  23     -51      52  0.593     12.3 2.4     14.2 2.7
E2 vs. NC       63  44    -7.7     187  0.088     23.2 4.5     14.2 2.7
CC vs. NC      -74 7.1     -85     -54 <0.001      3.7 0.7     14.2 2.7

cg documentation built on May 2, 2019, 9:26 a.m.