NormalAndTplot | R Documentation |
Specify plots to illustrate Normal and t Hypothesis Tests or Confidence Intervals.
NormalAndTplot(mean0, ...)
## Default S3 method:
NormalAndTplot(mean0=0,
mean1=NA,
xbar=NA,
df=Inf, n=1,
sd=1,
xlim=c(-3, 3)*sd/sqrt(n) + range(c(mean0, mean1, xbar), na.rm=TRUE),
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","binomial"),
type=c("hypothesis", "confidence"),
zaxis=FALSE, z1axis=FALSE,
cex.z=.5, cex.xbar=.5, cex.y=.5, cex.prob=.6, cex.top.axis=1,
cex.left.axis=1, cex.pb.axis=1,
cex.xlab=1, cex.ylab=1.5, cex.strip=1,
main=NA, xlab, ylab,
prob.labels=(type=="hypothesis"),
xhalf.multiplier=1,
yhalf.multiplier=1,
cex.main=1,
key.axis.padding=4.5,
number.vars=1,
sub=NULL,
NTmethod="default",
power=FALSE,
beta=FALSE,
...)
## S3 method for class 'htest'
NormalAndTplot(mean0, type="hypothesis", xlim=NULL, mean1=NA, ...,
xbar, sd, df, n, alpha.left, alpha.right, ## ignored
distribution.name, sub ## these input arguments will be ignored
)
mean0 |
Null hypothesis |
mean1 |
Alternative hypothesis |
xbar |
Observed |
sd |
Standard deviation in the data scale |
df |
Degrees of freedom for |
n |
Number of observations per group. |
main , xlab , ylab , xlim , ylim , sub |
Standard |
... |
Additional |
number.vars |
Number of variables. 1 for a one-sample test, 2 for two-sample tests and paired tests. |
alpha.left , alpha.right |
For |
float |
Logical. If |
ntcolors |
Vector of colors used in the graph. The default value is
|
digits.axis , digits.float , digits |
|
distribution.name |
Name of distribution. |
type |
"hypothesis" for a Hypothesis Test graph, or "confidence" for a Confidence Interval graph. |
zaxis , z1axis |
Logical or list. Should the |
cex.z , cex.xbar , cex.y , cex.prob , cex.top.axis , cex.left.axis , cex.pb.axis , cex.xlab , cex.ylab , cex.strip , cex.main |
|
key.axis.padding |
tuning constant to create additional room above the
graph for a larger |
prob.labels |
logical. If |
xhalf.multiplier , yhalf.multiplier |
Numerical tuning constants to control the width and height 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. |
NTmethod |
Character string used when
For the normal approximation to the binomial
( For the default situation of In all cases except the |
power , beta |
Logical. If |
The graphs produced by this single function cover most of the first semester
introductory Statistics course. The htest
method plots the
results of the stats::t.test
function.
NormalAndTplot
is built on xyplot
.
Most of the arguments detailed in xyplot
documentation work to
control the appearance of the plot.
"trellis"
object.
This function is built on lattice and latticeExtra.
It supersedes the similar function
normal.and.t.dist
built on base graphics that is used in many
displays in the book by Erich Neuwirth and me: R through Excel, Springer
(2009).
https://link.springer.com/book/10.1007/978-1-4419-0052-4. Many details,
particularly the
alternate color scheme and the concept of floating probability labels,
grew out of discussions that Erich and I have had since the book was
published.
The method for "htest"
objects incorporates ideas that Jay Kerns and I developed at the 2011 UseR! conference.
This version incorporates some ideas suggested by Moritz Heene.
Richard M. Heiberger (rmh@temple.edu)
NTplot
NTplot(mean0=0, mean1=2, xbar=1.8, xlim=c(-3, 5))
NTplot(mean0=0, mean1=2, xbar=1.8, xlim=c(-3, 5), distribution.name="t", df=4)
NTplot(mean0=100, sd=12, mean1=113, xbar=105, xlim=c(92, 120), n=20)
NTplot(mean0=100, sd=12, mean1=113, xbar=105, xlim=c(92, 120), n=20,
zaxis=TRUE, z1axis=TRUE)
NTplot(mean0=100, sd=12, xbar=105, xlim=c(92, 108), n=20, ntcolors="stoplight")
NTplot(xbar=95, sd=10, xlim=c(65, 125), type="confidence",
alpha.left=.025, alpha.right=.025)
x <- rnorm(12, mean=.78)
x.t <- t.test(x)
NTplot(x.t)
NTplot(x.t, type="confidence")
x.tg <- t.test(x, alternative="greater")
NTplot(x.tg)
y <- rnorm(12, mean=-.05)
xy.t <- t.test(x, y)
NTplot(xy.t)
NTplot(xy.t, type="confidence")
## Not run:
if (interactive())
NTplot(shiny=TRUE) ## with any other arguments for initialization of the shiny app.
## End(Not run)
## Not run:
## The partially transparent colors are:
black127="#0000007F" ## HH:::ColorWithAlpha("black")
green127="#00FF007F" ## HH:::ColorWithAlpha("green")
blue127 ="#0000FF7F" ## HH:::ColorWithAlpha("blue")
## this is the default set of colors that are assigned when
## ntcolors="original" or when ntcolors is not specified
c(col.alpha = "blue",
col.notalpha = "lightblue",
col.beta = "red",
col.power = "pink",
col.pvalue = "green",
col.pvaluetranslucent = green127,
col.critical = "gray50",
col.border = black127,
col.text = "black",
col.conf = "lightgreen")
NTplot( )
NTplot(mean1 = 2, )
NTplot( xbar=1)
NTplot(mean1 = 2, xbar=1)
NTplot(type="confidence")
## this is the set of colors that are assigned when ntcolors="stoplight"
c(col.alpha = "red",
col.notalpha = "honeydew2",
col.beta = "orange",
col.power = "pink",
col.pvalue = "blue",
col.pvaluetranslucent = blue127,
col.critical = "gray50",
col.border = black127,
col.text = "black",
col.conf = "lightgreen")
NTplot( ntcolors="stoplight")
NTplot(mean1 = 2, ntcolors="stoplight")
NTplot( xbar=1, ntcolors="stoplight")
NTplot(mean1 = 2, xbar=1, ntcolors="stoplight")
NTplot(type="confidence", ntcolors="stoplight")
## this is the set of colors that are assigned when ntcolors="BW"
c(col.alpha = "gray35",
col.notalpha = "gray85",
col.beta = "gray15",
col.power = "gray40",
col.pvalue = "gray50",
col.pvaluetranslucent = HH:::ColorWithAlpha("gray65"),
col.critical = "gray15",
col.border = "gray75",
col.text = "black",
col.conf = "gray45")
NTplot( ntcolors="BW")
NTplot(mean1 = 2, ntcolors="BW")
NTplot( xbar=1, ntcolors="BW")
NTplot(mean1 = 2, xbar=1, ntcolors="BW")
NTplot(type="confidence", ntcolors="BW")
## End(Not run)
## Not run:
## mean1 and xbar
NTplot(mean0=0, mean1=2, xbar=1.8, xlim=c(-3, 5))
NTplot(mean0=0, mean1=-2, xbar=-1.8, xlim=c(-5, 3),
alpha.left=.05, alpha.right=0)
NTplot(mean0=0, mean1=2, xbar=2.1, xlim=c(-3, 5),
alpha.left=.025, alpha.right=.025)
NTplot(mean0=0, mean1=-2, xbar=-2.1, xlim=c(-5, 3),
alpha.left=.025, alpha.right=.025)
## mean1
NTplot(mean0=0, mean1=2, xbar=NA, xlim=c(-3, 5))
NTplot(mean0=0, mean1=-2, xbar=NA, xlim=c(-5, 3),
alpha.left=.05, alpha.right=0)
NTplot(mean0=0, mean1=2, xbar=NA, xlim=c(-3, 5),
alpha.left=.025, alpha.right=.025)
NTplot(mean0=0, mean1=-2, xbar=NA, xlim=c(-5, 3),
alpha.left=.025, alpha.right=.025)
## xbar
NTplot(mean0=0, mean1=NA, xbar=1.8, xlim=c(-3, 5))
NTplot(mean0=0, mean1=NA, xbar=-1.8, xlim=c(-5, 3),
alpha.left=.05, alpha.right=0)
NTplot(mean0=0, mean1=NA, xbar=2.1, xlim=c(-3, 5),
alpha.left=.025, alpha.right=.025)
NTplot(mean0=0, mean1=NA, xbar=-2.1, xlim=c(-5, 3),
alpha.left=.025, alpha.right=.025)
## t distribution
## mean1 and xbar
NTplot(mean0=0, mean1=2, xbar=1.8, xlim=c(-3, 5),
distribution.name="t", df=4)
NTplot(mean0=0, mean1=-2, xbar=-1.8, xlim=c(-5, 3),
alpha.left=.05, alpha.right=0, distribution.name="t", df=4)
NTplot(mean0=0, mean1=2, xbar=2.1, xlim=c(-3, 5),
alpha.left=.025, alpha.right=.025, distribution.name="t", df=4)
NTplot(mean0=0, mean1=-2, xbar=-2.1, xlim=c(-5, 3),
alpha.left=.025, alpha.right=.025, distribution.name="t", df=4)
## mean1
NTplot(mean0=0, mean1=2, xbar=NA, xlim=c(-3, 5),
distribution.name="t", df=4)
NTplot(mean0=0, mean1=-2, xbar=NA, xlim=c(-5, 3),
alpha.left=.05, alpha.right=0, distribution.name="t", df=4)
NTplot(mean0=0, mean1=2, xbar=NA, xlim=c(-3, 5),
alpha.left=.025, alpha.right=.025, distribution.name="t", df=4)
NTplot(mean0=0, mean1=-2, xbar=NA, xlim=c(-5, 3),
alpha.left=.025, alpha.right=.025, distribution.name="t", df=4)
## xbar
NTplot(mean0=0, mean1=NA, xbar=1.8, xlim=c(-3, 5),
distribution.name="t", df=4)
NTplot(mean0=0, mean1=NA, xbar=-1.8, xlim=c(-5, 3),
alpha.left=.05, alpha.right=0, distribution.name="t", df=4)
NTplot(mean0=0, mean1=NA, xbar=2.1, xlim=c(-3, 5),
alpha.left=.025, alpha.right=.025, distribution.name="t", df=4)
NTplot(mean0=0, mean1=NA, xbar=-2.1, xlim=c(-5, 3),
alpha.left=.025, alpha.right=.025, distribution.name="t", df=4)
## confidence intervals
NTplot(mean0=0, xlim=c(-3, 4), type="confidence")
NTplot(xbar=01, xlim=c(-3, 4), type="confidence")
NTplot(mean0=0, xlim=c(-4, 3), type="confidence",
alpha.left=.05, alpha.right=0)
NTplot(mean0=0, xlim=c(-3, 3), type="confidence",
alpha.left=.025, alpha.right=.025)
NTplot(mean0=95, sd=10, xlim=c(65, 125), type="confidence",
alpha.left=.025, alpha.right=.025)
NTplot(mean0=95, sd=10, xlim=c(65, 125), type="confidence",
alpha.left=.025, alpha.right=.025,
distribution="t", df=10)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.