Specify plots to illustrate Normal and t Hypothesis Tests or Confidence Intervals, including normal approximation to the binomial.
1 2 3 4 5 6 7 8 9 10 11 12 13
NTplot(mean0, ...) ## Default S3 method: NTplot(mean0=0, ..., shiny=FALSE, distribution.name = c("normal","z","t","binomial")) ## S3 method for class 'htest' NTplot(mean0, ..., shiny=FALSE, NTmethod="htest") ## S3 method for class 'power.htest' NTplot(mean0, ..., shiny=FALSE, xbar=NA, ## these input values are used mean1, n, df, sd, distribution.name, sub, ## these input values ignored alpha.left, alpha.right, number.vars) ## these input values ignored ## NTplot(NTplot(htest.object), n=20) ## allows override of arguments ## S3 method for class 'NormalAndTplot' NTplot(mean0, ..., shiny=FALSE)
For the default method,
Other arguments, selected from the options for the
These variables are ignored here. They
are captured so they won't interfere with similarly named variables
that are generated in the
Character string used when
The graphs produced by this single function cover most of the first semester
introductory Statistics course.
All options of the
are accepted and displayed.
NTplot is built on
Most of the arguments detailed in
xyplot documentation work to
control the appearance of the plot.
The shiny app (called when the argument
provides animated sliders for the means, standard
deviation, xlimits, significance levels, df, and n. The df and n are
rounded to integers for the sliders (relevant for
power.htest objects). Checkboxes and Radio buttons are available
various display options
When you have a graph on the shiny window that you wish to keep, click on the "Display Options" tab, and then on the "Display Call" radio button. The main shiny window will show an R command which will reproduce the current plot. Pick it up with the mouse and drop it into an R console window.
To get out of the shiny window and return to an interactive R console,
move the cursor back to the console window and interrupt the shiny call, usually
"trellis" object. The object can be plotted or fed back into the
NTplot function with argument
shiny=TRUE to allow
interactive graphical investigation of the hypothesis test or confidence
The attributes of the object\
NTobj <- NTplot()\
attr(NTobj, "scales") and
attr(NTobj, "prob") make the
data values and probability values accessible for further R
cat(attr(NT.object, "call"), "\n")
displays a statement that can be copied back into R to reproduce the graph.
cat() is needed to unescape embedded quotes.
is a list that can be used with
do.call to reproduce the graph.
do.call(NTplot, attr(NT.object, "call.list")). This is usually
not needed by the user because the simpler statement
does it for you.
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
http://www.springer.com/978-1-4419-0051-7. Many details,
alternate color scheme and the concept of floating probability labels,
grew out of discussions that Erich and I have had since the book was
It 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 (email@example.com)
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
x1 <- rnorm(12) x2 <- rnorm(12, mean=.5) NT.object <- NTplot(mean0=0, mean1=1) NT.object attr(NT.object, "scales") attr(NT.object, "prob") cat(attr(NT.object, "call"), "\n") ## the cat() is needed to unescape embedded quotes. NTplot(t.test(x1, x2)) NTplot(power.t.test(power = .90, delta = 1, alternative = "one.sided")) ## Not run: ## 22 distinct calls are shown in demo(NTplot, ask=FALSE) ## End(Not run) ## Not run: ## these are interactive and do not work in static checking of the code NTplot(mean0=0, mean1=1, shiny=TRUE) NTplot(shiny=TRUE, px.height=475) ## default value is 575 NTplot(t.test(x1, x2), shiny=TRUE, mean1=1) NTplot(power.t.test(power = .90, delta = 1, alternative = "one.sided"), shiny=TRUE) NTplot(NT.object, shiny=TRUE) ## run the shiny app shiny::runApp(system.file("shiny/NTplot", package="HH")) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.