A function to request T-test plots on a call to proc_ttest. The function allows you to specify the type of T-Test plots to produce. By default, it produces plots appropriate to the analysis being performed. You may also request specific plots by passing a vector of plot names to the type parameter.

ttestplot(type = "default", panel = TRUE, showh0 = FALSE)

Arguments

type

The type(s) of plot to create. Multiple types should be passed as a vector of strings. Valid values are "agreement", "boxplot", "histogram", "interval", "profiles", "qqplot", "summary". The default value is "default", which will produce default plots appropriate for the analysis. You may use the v function to pass the plot keywords unquoted.

panel

Whether or not to display the summary plot combined into in a single panel. Default is TRUE. A value of FALSE will create individual "histogram" and "boxplot" charts instead. This parameter is equivalent to the "unpack" keyword in SAS.

showh0

Whether or not to show the null hypothesis on the chart. Default is FALSE. If this parameter is TRUE, a vertical line will be created on some charts to show the value specified for the "h0=" option on proc_ttest.

Details

Plots produced by proc_ttest can change depending on the type of analysis being performed.

For one sample T-Tests, the function creates single variable charts. The "summary" and "qqplot" charts are generated by default. For this type of analysis, it is helpful to set the "showh0" parameter to TRUE so you can see the null hypothesis on the chart.

For two sample T-Tests, the function produces two variable charts. For example, on a two sample T-Test, the "histogram" chart will show histograms for each class value on the same plot. Likewise, the "boxplot" and "qqplot" are separated for each variable. The "interval" plot is split into "Satterthwaite" and "Pooled" intervals. Note that the "h0" option also produces a null hypothesis line for the "interval" plot, if requested.

For a paired analysis, the "profiles" and "agreement" charts are available in addition to the "histogram", "boxplot", "interval", and "qqplot" charts. Paired analysis also produces single variable charts.

To see all plots available for the requested analysis, pass the keyword "all" to the type parameter.

Any requested plots will be displayed on interactive reports only. Plots are created as jpeg files, and stored in a temp directory. Those temporary files are then referenced by the interactive report to display the graphic.

If desired, you may output the report objects and pass to proc_print. To do this, set output = report on the call to proc_freq, and pass the entire list to proc_print.

Plots

The type parameter allows you to request several types of T-Test plots. Below are the types of plots that are supported. The list shows the plot type keyword needed to request the plot, and a brief description:

  • agreement: An agreement plot for the input data. Only available for paired comparisons.

  • boxplot: Displays a box and whisker plot for group comparisons, including confidence intervals (if appropriate).

  • histogram: A histogram with normal curve and kernel density overlays.

  • interval: Visualizes the confidence intervals for means.

  • profiles: A line plot mapping responses between analysis variables. Available only for paired analysis.

  • qqplot: A quantile-quantile plot used to assess the assumption of normality.

  • summary: Combines the histogram and boxplot charts onto the same panel. For two-sample T-Tests, both the histogram and boxplots are separated for each class value.

The above plots may be requested as a vector of keywords to the plots parameter on proc_ttest, or as vector of values to the type parameter on ttestplots.

Note that, when passed as a vector of keywords, only the requested plots will be produced. That is to say, the "only" keyword in SAS is implied at all times for proc_ttest.

Discrepancies with SAS

The histogram binning algorithm in R is different from the binning algorithm in SAS®. R uses a "Sturges" algorithm, which more accurately represents the distribution of the data. This algorithm may produce a different number of bins and different height of bars than the corresponding SAS chart.

Plots generated by proc_ttest may also have some spacing, color, and shape discrepancies with the corresponding SAS charts. The information conveyed is expected to be similar.

See also

Examples

library(procs)

# Turn off printing for CRAN checks
options("procs.print" = FALSE)

# View sample data
sleep
#    extra group ID
# 1    0.7     1  1
# 2   -1.6     1  2
# 3   -0.2     1  3
# 4   -1.2     1  4
# 5   -0.1     1  5
# 6    3.4     1  6
# 7    3.7     1  7
# 8    0.8     1  8
# 9    0.0     1  9
# 10   2.0     1 10
# 11   1.9     2  1
# 12   0.8     2  2
# 13   1.1     2  3
# 14   0.1     2  4
# 15  -0.1     2  5
# 16   4.4     2  6
# 17   5.5     2  7
# 18   1.6     2  8
# 19   4.6     2  9
# 20   3.4     2 10


# Example 1: plots = TRUE
proc_ttest(sleep,
           var = "extra",
           class = "group",
           plots = TRUE)

# Example 2: plots = "all"
proc_ttest(sleep,
           var = "extra",
           class = "group",
           plots = "all")

# Example 3: plots = {vector}
proc_ttest(sleep,
           var = "extra",
           class = "group",
           plots = c("histogram", "boxplot", "interval"))

# Example 4: plots = ttestplot()
proc_ttest(sleep,
           var = "extra",
           class = "group",
           plots = ttestplot("summary", panel = FALSE))