HH (version 3.1-8)

NormalAndTplot: Specify plots to illustrate Normal and t Hypothesis Tests or Confidence Intervals.

Description

Specify plots to illustrate Normal and t Hypothesis Tests or Confidence Intervals.

Usage

NormalAndTplot(mean0, ...)
## S3 method for class 'default':
NormalAndTplot(mean0=0,
             mean1=NA,
             xbar=NA,
             sd=1, df=Inf, n=1,
             xlim=c(-3, 3), ylim, alpha.right=.05, alpha.left=0,
             float=TRUE, ntcolors="original",
             digits=4, digits.axis=digits, digits.float=digits,
             distribution.name=c("normal","z","t"),
             type=c("hypothesis", "confidence"),
             zaxis=FALSE, z1axis=FALSE,
             cex.z=.5, cex.prob=.6, cex.top.axis=1,
             main, xlab, ylab,
             prob.labels=(type=="hypothesis"),
             xhalf.multiplier=1,
             cex.main=1,
             key.axis.padding=4.5, ...)
## S3 method for class 'htest':
NormalAndTplot(mean0, type="hypothesis", xlim=NULL, ...,
             xbar, sd, df, n, alpha.left, alpha.right, distribution.name, sub
             ## these input arguments sfter ... will be ignored
             )

Arguments

mean0
Null hypothesis $mu_0$. When graphing a confidence interval, mean0 will be used for xbar should xbar itself have the value NA.
mean1
Alternative hypothesis $mu_1$.
xbar
Observed $\bar(x)$.
sd
Standard deviation $\sigma$ for normal-, or $s$ for $t$-distribution.
df
Degrees of freedom for $t$-distribution.
n
Number of observations.
main, xlab, ylab, xlim, ylim, sub
Standard xyplot arguments. Default values are constructed if these arguments are missing.
...
Additional xyplot arguments.
alpha.left, alpha.right
For type="hypothesis", the sum of these two numbers is the probability of the Type I Error $\alpha$. When both of these numbers are positive, there is a two-sided test. Note that it is not required that they be equal. If one of the numbers
float
Logical. If TRUE, then the probabilities $\alpha$, $\beta$, power, and $p$-values or the confidence value are displayed on the graph. If FALSE, these values are not displayed.
ntcolors
Vector of colors used in the graph. The default value is "original", which implies the ten colors c(col.alpha = "blue", col.notalpha = "lightblue", col.beta = "red", col.power = "pink", col.pvalue = "green", col.pvaluetransluce
digits.axis, digits.float, digits
digits.axis is the number of significant digits for the top axis. digits.float is the number of significant digits for the floating probability values on the graph. digits is a convenience argument to s
distribution.name
Name of distribution.
type
"hypothesis" for a Hypothesis Test graph, or "confidence" for a Confidence Interval graph.
z1axis, zaxis
Logical. Should the $z_1$-axis centered on $mu_1$ or the $z_0$-axis centered on $mu_0$ be displayed?
cex.z, cex.prob, cex.top.axis, cex.main
cex.z is the cex value for the $z$ and $z_1$ axes on the plot. cex.prob is the cex value for the floating probabilities on the graph. cex.top.axis is the cex value
key.axis.padding
tuning constant to create additional room above the graph for a larger cex.main to fit.
prob.labels
logical. If TRUE label the floating probability values with their name, such as $alpha$. If FALSE, then don't label them. The default is TRUE for type="hypothesis" and FALSE
xhalf.multiplier
Numerical tuning constant to control the width of the floating probability values. Empirically, we need a smaller value for the shiny app then we need for direct writing onto a graphic device.

Value

  • "trellis" object.

Details

This graphs produced by this single function cover most of the first semester introductory Statistics course.

Examples

Run this code
NormalAndTplot(mean0=0, mean1=2,  xbar=1.8,  xlim=c(-3, 5))
   NormalAndTplot(mean0=0, mean1=2,  xbar=1.8,  xlim=c(-3, 5), distribution.name="t", df=4)
   NormalAndTplot(mean0=100, sd=12, mean1=113,  xbar=105,  xlim=c(92, 120), n=20)
   NormalAndTplot(mean0=100, sd=12, mean1=113,  xbar=105,  xlim=c(92, 120), n=20, z1axis=TRUE)
   NormalAndTplot(mean0=100, sd=12,  xbar=105,  xlim=c(92, 108), n=20, ntcolors="stoplight")
   NormalAndTplot(xbar=95, sd=10, xlim=c(65, 125), type="confidence",
                  alpha.left=.025, alpha.right=.025)

shiny::runApp(file.path(system.file(package="HH"), "shiny"))

## mean1 and xbar
  NormalAndTplot(mean0=0, mean1=2,  xbar=1.8,  xlim=c(-3, 5))
  NormalAndTplot(mean0=0, mean1=-2, xbar=-1.8, xlim=c(-5, 3),
                 alpha.left=.05,  alpha.right=0)
  NormalAndTplot(mean0=0, mean1=2,  xbar=2.1,  xlim=c(-3, 5),
                 alpha.left=.025, alpha.right=.025)
  NormalAndTplot(mean0=0, mean1=-2, xbar=-2.1, xlim=c(-5, 3),
                 alpha.left=.025, alpha.right=.025)

## mean1
  NormalAndTplot(mean0=0, mean1=2,  xbar=NA, xlim=c(-3, 5))
  NormalAndTplot(mean0=0, mean1=-2, xbar=NA, xlim=c(-5, 3),
                 alpha.left=.05,  alpha.right=0)
  NormalAndTplot(mean0=0, mean1=2,  xbar=NA, xlim=c(-3, 5),
                 alpha.left=.025, alpha.right=.025)
  NormalAndTplot(mean0=0, mean1=-2, xbar=NA, xlim=c(-5, 3),
                 alpha.left=.025, alpha.right=.025)

## xbar
  NormalAndTplot(mean0=0, mean1=NA, xbar=1.8,  xlim=c(-3, 5))
  NormalAndTplot(mean0=0, mean1=NA, xbar=-1.8, xlim=c(-5, 3),
                 alpha.left=.05,  alpha.right=0)
  NormalAndTplot(mean0=0, mean1=NA, xbar=2.1,  xlim=c(-3, 5),
                 alpha.left=.025, alpha.right=.025)
  NormalAndTplot(mean0=0, mean1=NA, xbar=-2.1, xlim=c(-5, 3),
                 alpha.left=.025, alpha.right=.025)

## t distribution
## mean1 and xbar
  NormalAndTplot(mean0=0, mean1=2,  xbar=1.8,  xlim=c(-3, 5),
                 distribution.name="t", df=4)
  NormalAndTplot(mean0=0, mean1=-2, xbar=-1.8, xlim=c(-5, 3),
                 alpha.left=.05,  alpha.right=0, distribution.name="t", df=4)
  NormalAndTplot(mean0=0, mean1=2,  xbar=2.1,  xlim=c(-3, 5),
                 alpha.left=.025, alpha.right=.025, distribution.name="t", df=4)
  NormalAndTplot(mean0=0, mean1=-2, xbar=-2.1, xlim=c(-5, 3),
                 alpha.left=.025, alpha.right=.025, distribution.name="t", df=4)

## mean1
  NormalAndTplot(mean0=0, mean1=2,  xbar=NA, xlim=c(-3, 5),
                 distribution.name="t", df=4)
  NormalAndTplot(mean0=0, mean1=-2, xbar=NA, xlim=c(-5, 3),
                 alpha.left=.05,  alpha.right=0, distribution.name="t", df=4)
  NormalAndTplot(mean0=0, mean1=2,  xbar=NA, xlim=c(-3, 5),
                 alpha.left=.025, alpha.right=.025, distribution.name="t", df=4)
  NormalAndTplot(mean0=0, mean1=-2, xbar=NA, xlim=c(-5, 3),
                 alpha.left=.025, alpha.right=.025, distribution.name="t", df=4)

## xbar
  NormalAndTplot(mean0=0, mean1=NA, xbar=1.8,  xlim=c(-3, 5),
                 distribution.name="t", df=4)
  NormalAndTplot(mean0=0, mean1=NA, xbar=-1.8, xlim=c(-5, 3),
                 alpha.left=.05,  alpha.right=0, distribution.name="t", df=4)
  NormalAndTplot(mean0=0, mean1=NA, xbar=2.1,  xlim=c(-3, 5),
                 alpha.left=.025, alpha.right=.025, distribution.name="t", df=4)
  NormalAndTplot(mean0=0, mean1=NA, xbar=-2.1, xlim=c(-5, 3),
                 alpha.left=.025, alpha.right=.025, distribution.name="t", df=4)

## confidence intervals

  NormalAndTplot(mean0=0, xlim=c(-3, 4), type="confidence")
  NormalAndTplot(xbar=01, xlim=c(-3, 4), type="confidence")
  NormalAndTplot(mean0=0, xlim=c(-4, 3), type="confidence",
                 alpha.left=.05,  alpha.right=0)
  NormalAndTplot(mean0=0, xlim=c(-3, 3), type="confidence",
                 alpha.left=.025, alpha.right=.025)
  NormalAndTplot(mean0=95, sd=10, xlim=c(65, 125), type="confidence",
                 alpha.left=.025, alpha.right=.025)
  NormalAndTplot(mean0=95, sd=10, xlim=c(65, 125), type="confidence",
                 alpha.left=.025, alpha.right=.025,
                 distribution="t", df=10)

Run the code above in your browser using DataCamp Workspace