[IPSUR-commits] r133 - in pkg/IPSUR: . R inst/doc man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sat Jan 9 19:21:42 CET 2010
Author: gkerns
Date: 2010-01-09 19:21:41 +0100 (Sat, 09 Jan 2010)
New Revision: 133
Added:
pkg/IPSUR/R/plothtest.R
pkg/IPSUR/man/plothtest.Rd
Modified:
pkg/IPSUR/DESCRIPTION
pkg/IPSUR/inst/doc/IPSUR.Rnw
pkg/IPSUR/man/IPSUR-package.Rd
Log:
some small changes, and added plot methods for hypothesis tests
Modified: pkg/IPSUR/DESCRIPTION
===================================================================
--- pkg/IPSUR/DESCRIPTION 2010-01-09 06:15:01 UTC (rev 132)
+++ pkg/IPSUR/DESCRIPTION 2010-01-09 18:21:41 UTC (rev 133)
@@ -5,7 +5,7 @@
Date: 2010-01-05
Author: G. Jay Kerns
Maintainer: G. Jay Kerns <gkerns at ysu.edu>
-Suggests: actuar, aplpack, coin, DAAG, distr, distrEx, distrTeach, e1071, exactRankTests, HH, Hmisc, lattice, lmtest, mvtnorm, odfWeave, prob, qcc, RcmdrPlugin.IPSUR (>= 0.1-6), Rcmdr, reshape, scatterplot3d, TeachingDemos (>= 2.5), vcd
+Suggests: actuar, aplpack, coin, DAAG, distr, distrEx, distrTeach, e1071, exactRankTests, HH (>= 2.1-32), Hmisc, lattice, lmtest, mvtnorm, odfWeave, prob, qcc, RcmdrPlugin.IPSUR (>= 0.1-6), Rcmdr, reshape, scatterplot3d, TeachingDemos (>= 2.5), vcd
Description: This package contains the Sweave source code used to generate IPSUR, an introductory probability and statistics textbook, alongside other supplementary materials such as the parsed R code for the book and data for the examples and exercises. The book is released under the GNU Free Documentation License.
License: GPL (>= 3)
LazyLoad: yes
Added: pkg/IPSUR/R/plothtest.R
===================================================================
--- pkg/IPSUR/R/plothtest.R (rev 0)
+++ pkg/IPSUR/R/plothtest.R 2010-01-09 18:21:41 UTC (rev 133)
@@ -0,0 +1,116 @@
+# Written by G. Jay Kerns, 9/11/2009
+# Another, much better version currently in development
+
+
+###################################################
+plot.htest <- function (x, hypoth.or.conf = 'Hypoth',...) {
+require(HH)
+if (x$method == "1-sample proportions test with continuity correction" || x$method == "1-sample proportions test without continuity correction"){
+ mu <- x$null.value
+ obs.mean <- x$estimate
+ n <- NA
+ std.dev <- abs(obs.mean - mu)/sqrt(x$statistic)
+ deg.freedom <- NA
+ if(x$alternative == "two.sided"){
+ alpha.right <- (1 - attr(x$conf.int, "conf.level"))/2
+ Use.alpha.left <- TRUE
+ Use.alpha.right <- TRUE
+ } else if (x$alternative == "less") {
+ alpha.right <- 1 - attr(x$conf.int, "conf.level")
+ Use.alpha.left <- TRUE
+ Use.alpha.right <- FALSE
+ } else {
+ alpha.right <- 1 - attr(x$conf.int, "conf.level")
+ Use.alpha.left <- FALSE
+ Use.alpha.right <- TRUE
+ }
+} else if (x$method == "One Sample z-test"){
+ mu <- x$null.value
+ obs.mean <- x$estimate
+ n <- x$parameter[1]
+ std.dev <- x$parameter[2]
+ deg.freedom <- NA
+ if(x$alternative == "two.sided"){
+ alpha.right <- (1 - attr(x$conf.int, "conf.level"))/2
+ Use.alpha.left <- TRUE
+ Use.alpha.right <- TRUE
+ } else if (x$alternative == "less") {
+ alpha.right <- 1 - attr(x$conf.int, "conf.level")
+ Use.alpha.left <- TRUE
+ Use.alpha.right <- FALSE
+ } else {
+ alpha.right <- 1 - attr(x$conf.int, "conf.level")
+ Use.alpha.left <- FALSE
+ Use.alpha.right <- TRUE
+ }
+} else if (x$method == "One Sample t-test" || x$method == "Paired t-test"){
+ mu <- x$null.value
+ obs.mean <- x$estimate
+ n <- x$parameter + 1
+ std.dev <- x$estimate/x$statistic*sqrt(n)
+ deg.freedom <- x$parameter
+ if(x$alternative == "two.sided"){
+ alpha.right <- (1 - attr(x$conf.int, "conf.level"))/2
+ Use.alpha.left <- TRUE
+ Use.alpha.right <- TRUE
+ } else if (x$alternative == "less") {
+ alpha.right <- 1 - attr(x$conf.int, "conf.level")
+ Use.alpha.left <- TRUE
+ Use.alpha.right <- FALSE
+ } else {
+ alpha.right <- 1 - attr(x$conf.int, "conf.level")
+ Use.alpha.left <- FALSE
+ Use.alpha.right <- TRUE
+ }
+} else if (x$method == "Welch Two Sample t-test"){
+ mu <- x$null.value
+ obs.mean <- -diff(x$estimate)
+ n <- x$parameter + 2
+ std.dev <- obs.mean/x$statistic*sqrt(n)
+ deg.freedom <- x$parameter
+ if(x$alternative == "two.sided"){
+ alpha.right <- (1 - attr(x$conf.int, "conf.level"))/2
+ Use.alpha.left <- TRUE
+ Use.alpha.right <- TRUE
+ } else if (x$alternative == "less") {
+ alpha.right <- 1 - attr(x$conf.int, "conf.level")
+ Use.alpha.left <- TRUE
+ Use.alpha.right <- FALSE
+ } else {
+ alpha.right <- 1 - attr(x$conf.int, "conf.level")
+ Use.alpha.left <- FALSE
+ Use.alpha.right <- TRUE
+ }
+} else if (x$method == " Two Sample t-test"){
+ mu <- x$null.value
+ obs.mean <- -diff(x$estimate)
+ n <- x$parameter + 2
+ std.dev <- obs.mean/x$statistic*sqrt(n)
+ deg.freedom <- x$parameter
+ if(x$alternative == "two.sided"){
+ alpha.right <- (1 - attr(x$conf.int, "conf.level"))/2
+ Use.alpha.left <- TRUE
+ Use.alpha.right <- TRUE
+ } else if (x$alternative == "less") {
+ alpha.right <- 1 - attr(x$conf.int, "conf.level")
+ Use.alpha.left <- TRUE
+ Use.alpha.right <- FALSE
+ } else {
+ alpha.right <- 1 - attr(x$conf.int, "conf.level")
+ Use.alpha.left <- FALSE
+ Use.alpha.right <- TRUE
+ }
+}
+
+return( normal.and.t.dist(mu.H0 = mu, obs.mean = obs.mean,
+ std.dev = std.dev, n = n,
+ deg.freedom = deg.freedom,
+ alpha.right = alpha.right,
+ Use.obs.mean = TRUE,
+ Use.alpha.left = Use.alpha.left,
+ Use.alpha.right = Use.alpha.right,
+ hypoth.or.conf = hypoth.or.conf))
+}
+
+
+
Modified: pkg/IPSUR/inst/doc/IPSUR.Rnw
===================================================================
--- pkg/IPSUR/inst/doc/IPSUR.Rnw 2010-01-09 06:15:01 UTC (rev 132)
+++ pkg/IPSUR/inst/doc/IPSUR.Rnw 2010-01-09 18:21:41 UTC (rev 133)
@@ -11920,10 +11920,8 @@
# this is the example from the help file
nheads <- rbinom(1, size = 100, prob = 0.45)
prop.test(x = nheads, n = 100, p = 0.50, alternative = "two.sided", conf.level = 0.95, correct = TRUE)
-prop.test(x = nheads, n = 100, p = 0.50, alternative = "two.sided", conf.level = 0.95, correct = FALSE)
+prop.test(x = nheads, n = 100, p = 0.50, alternative = "two.sided", conf.level
-@
-
%
\begin{figure}
\begin{centering}
@@ -11933,7 +11931,7 @@
@
\par\end{centering}
-\caption{Hypothesis test plot from the \texttt{HH} package}
+\caption{Hypothesis test plot from the \texttt{IPSUR} package}
\end{figure}
Modified: pkg/IPSUR/man/IPSUR-package.Rd
===================================================================
--- pkg/IPSUR/man/IPSUR-package.Rd 2010-01-09 06:15:01 UTC (rev 132)
+++ pkg/IPSUR/man/IPSUR-package.Rd 2010-01-09 18:21:41 UTC (rev 133)
@@ -7,7 +7,7 @@
Introduction to Probability and Statistics Using R
}
\description{
-This is a self-contained textbook on probability and statistics for students with differential and integral calculus. It is released under the GNU Free Documentation License.
+This package contains the Sweave source code used to generate IPSUR, an introductory probability and statistics textbook, alongside other supplementary materials such as the parsed R code for the book and data for the examples and exercises. The book is released under the GNU Free Documentation License.
}
\details{
\tabular{ll}{
@@ -15,10 +15,10 @@
Type: \tab Package\cr
Version: \tab 1.0\cr
Date: \tab 2009-12-08\cr
-License: \tab file LICENSE\cr
+License: \tab GPL (>= 3)\cr
LazyLoad: \tab yes\cr
}
-This package is a textbook written at the introductory level to introduce students to probability and statistics using R. After loading the package with library(R), the book may be read by issuing the command read(IPSUR) at the command line.
+This package is a textbook written at the introductory level to introduce students to probability and statistics using R. After loading the package with library(IPSUR), the book may be read by issuing the command read(IPSUR) at the command line.
}
\author{
G. Jay Kerns
@@ -26,7 +26,5 @@
Maintainer: G. Jay Kerns <gkerns at ysu.edu>
}
-\references{
-Literature or other references for background information
-}
+
\keyword{package}
Added: pkg/IPSUR/man/plothtest.Rd
===================================================================
--- pkg/IPSUR/man/plothtest.Rd (rev 0)
+++ pkg/IPSUR/man/plothtest.Rd 2010-01-09 18:21:41 UTC (rev 133)
@@ -0,0 +1,31 @@
+\name{plot}
+\alias{plot.htest}
+
+\title{Plotting Hypothesis Tests}
+\description{
+ This function allows the user to plot a saved hypothesis test object, including normal curves, critical values, shading, and p-values. It requires the HH package and the \code{normal.and.t.dist} function written by Dr. Richard Heiberger. Please note that a much better version of this function is currently under development.
+}
+
+\usage{
+\method{plot}{htest}(x, hypoth.or.conf = 'Hypoth', \ldots)
+}
+
+\arguments{
+ \item{x}{an \code{htest} object that is the result of a hypothesis test.}
+ \item{hypoth.or.conf}{a switch to choose between plots for hypothesis tests or confidence intervals}
+ \item{\ldots}{further arguments to be passed to or from other methods.}
+}
+
+\details{
+This is a plot method for hypothesis tests or confidence intervals which uses the \code{normal.and.t.dist} function in the \code{HH} package.
+}
+
+\value{
+ A plot of the normal or Student's t distribution associated with the hypothesis test or confidence interval. Critical values and p-values are displayed.
+}
+
+\author{G. Jay Kerns \email{gkerns at ysu.edu}}
+
+\seealso{\code{\link[HH]{normal.and.t.dist}}}
+
+\keyword{misc}
More information about the IPSUR-commits
mailing list