[Sleuth2-commits] r37 - in pkg/Sleuth3: . inst/doc man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Aug 3 18:26:35 CEST 2012


Author: berwin
Date: 2012-08-03 18:26:35 +0200 (Fri, 03 Aug 2012)
New Revision: 37

Added:
   pkg/Sleuth3/man/case0601.Rd
   pkg/Sleuth3/man/case0602.Rd
   pkg/Sleuth3/man/case0701.Rd
   pkg/Sleuth3/man/case0702.Rd
   pkg/Sleuth3/man/case0801.Rd
   pkg/Sleuth3/man/case0802.Rd
   pkg/Sleuth3/man/case0901.Rd
   pkg/Sleuth3/man/case0902.Rd
   pkg/Sleuth3/man/case1001.Rd
   pkg/Sleuth3/man/case1002.Rd
   pkg/Sleuth3/man/case1101.Rd
   pkg/Sleuth3/man/case1102.Rd
   pkg/Sleuth3/man/case1201.Rd
   pkg/Sleuth3/man/case1202.Rd
   pkg/Sleuth3/man/case1301.Rd
   pkg/Sleuth3/man/case1302.Rd
   pkg/Sleuth3/man/case1401.Rd
   pkg/Sleuth3/man/case1402.Rd
Modified:
   pkg/Sleuth3/DESCRIPTION
   pkg/Sleuth3/inst/doc/Sleuth3-manual.pdf
   pkg/Sleuth3/man/Sleuth3-package.Rd
   pkg/Sleuth3/man/Sleuth3Manual.Rd
   pkg/Sleuth3/man/case0101.Rd
   pkg/Sleuth3/man/case0102.Rd
   pkg/Sleuth3/man/case0201.Rd
   pkg/Sleuth3/man/case0202.Rd
   pkg/Sleuth3/man/case0301.Rd
   pkg/Sleuth3/man/case0302.Rd
   pkg/Sleuth3/man/case0401.Rd
   pkg/Sleuth3/man/case0402.Rd
   pkg/Sleuth3/man/case0501.Rd
   pkg/Sleuth3/man/case0502.Rd
Log:
Sleuth3:
Replaced .Rd files with new versions provided by Dan.
Added new .Rd files provided by Dan.
Updated publication date in DESCRIPTION file.
Bumped version number, hence also updated inst/doc/Sleuth3-manual.pdf


Modified: pkg/Sleuth3/DESCRIPTION
===================================================================
--- pkg/Sleuth3/DESCRIPTION	2012-07-24 16:20:24 UTC (rev 36)
+++ pkg/Sleuth3/DESCRIPTION	2012-08-03 16:26:35 UTC (rev 37)
@@ -1,15 +1,15 @@
 Package: Sleuth3
 Title: Data sets from Ramsey and Schafer's "Statistical Sleuth (3rd ed)"
-Version: 0.0-4
-Date: 2012-06-24
+Version: 0.0-5
+Date: 2012-08-03
 Author:  Original by F.L. Ramsey and D.W. Schafer,
     modifications by Daniel W. Schafer, Jeannie Sifneos and Berwin A. Turlach
-Description: Data sets from Ramsey, F.L. and Schafer, D.W. (2012), "The
+Description: Data sets from Ramsey, F.L. and Schafer, D.W. (2013), "The
     Statistical Sleuth: A Course in Methods of Data Analysis (3rd
-    ed)", Duxbury. 
+    ed)", Cengage Learning. 
 Maintainer: Berwin A Turlach <Berwin.Turlach at gmail.com>
 LazyData: yes
 Depends: R (>= 2.12.0)
-Suggests: lattice, multcomp
+Suggests: lattice, multcomp, car, leaps
 License: GPL (>= 2)
 URL: http://r-forge.r-project.org/projects/sleuth2/

Modified: pkg/Sleuth3/inst/doc/Sleuth3-manual.pdf
===================================================================
(Binary files differ)

Modified: pkg/Sleuth3/man/Sleuth3-package.Rd
===================================================================
--- pkg/Sleuth3/man/Sleuth3-package.Rd	2012-07-24 16:20:24 UTC (rev 36)
+++ pkg/Sleuth3/man/Sleuth3-package.Rd	2012-08-03 16:26:35 UTC (rev 37)
@@ -6,7 +6,7 @@
 The R Sleuth3 package
 }
 \description{
-Data sets from Ramsey and Schafer's "Statistical Sleuth (2nd ed)"
+Data sets from Ramsey and Schafer's "Statistical Sleuth (3rd ed)"
 }
 \details{This package contains a variety of datasets.  For a complete
   list, use \code{library(help="Sleuth3")} or

Modified: pkg/Sleuth3/man/Sleuth3Manual.Rd
===================================================================
--- pkg/Sleuth3/man/Sleuth3Manual.Rd	2012-07-24 16:20:24 UTC (rev 36)
+++ pkg/Sleuth3/man/Sleuth3Manual.Rd	2012-08-03 16:26:35 UTC (rev 37)
@@ -11,8 +11,8 @@
 Sleuth3Manual()
 }
 \references{
-  Ramsey, F.L. and Schafer, D.W. (2002). \emph{The Statistical Sleuth: A
-    Course in Methods of Data Analysis (3rd ed)}, Duxbury.
+  Ramsey, F.L. and Schafer, D.W. (2013). \emph{The Statistical Sleuth: A
+    Course in Methods of Data Analysis (3rd ed)}, Cengage Learning.
 }
 \author{
   Berwin A Turlach \email{Berwin.Turlach at gmail.com}

Modified: pkg/Sleuth3/man/case0101.Rd
===================================================================
--- pkg/Sleuth3/man/case0101.Rd	2012-07-24 16:20:24 UTC (rev 36)
+++ pkg/Sleuth3/man/case0101.Rd	2012-08-03 16:26:35 UTC (rev 37)
@@ -18,8 +18,8 @@
   }
 }
 \source{
-  Ramsey, F.L. and Schafer, D.W. (2012). \emph{The Statistical Sleuth: A
-    Course in Methods of Data Analysis (3rd ed)}, Duxbury.
+  Ramsey, F.L. and Schafer, D.W. (2013). \emph{The Statistical Sleuth: A
+    Course in Methods of Data Analysis (3rd ed)}, Cengage Learning.
 }
 \references{
   Amabile, T. (1985). Motivation and Creativity: Effects of Motivational
@@ -29,9 +29,9 @@
 \examples{
 attach(case0101)  
 str(case0101)  
-boxplot(Score ~ Treatment)  
+boxplot(Score ~ Treatment)  # Basic boxplots for each level of Treatment
 
-boxplot(Score ~ Treatment, 
+boxplot(Score ~ Treatment,  # Boxplots with labels
   ylab= "Average Creativity Score From 11 Judges (on a 40-point scale)",  
   names=c("23 'Extrinsic' Group Students","24 'Intrinsic' Group Students"), 
   main= "Haiku Creativity Scores for 47 Creative Writing Students") 

Modified: pkg/Sleuth3/man/case0102.Rd
===================================================================
--- pkg/Sleuth3/man/case0102.Rd	2012-07-24 16:20:24 UTC (rev 36)
+++ pkg/Sleuth3/man/case0102.Rd	2012-08-03 16:26:35 UTC (rev 37)
@@ -17,8 +17,8 @@
   }
 }
 \source{
-  Ramsey, F.L. and Schafer, D.W. (2012). \emph{The Statistical Sleuth: A
-    Course in Methods of Data Analysis (3rd ed)}, Duxbury.
+  Ramsey, F.L. and Schafer, D.W. (2013). \emph{The Statistical Sleuth: A
+    Course in Methods of Data Analysis (3rd ed)}, Cengage Learning.
 }
 \references{
   Roberts, H.V. (1979). Harris Trust and Savings Bank: An Analysis of
@@ -31,7 +31,7 @@
 }
 \examples{
 attach(case0102)
-str(case0102)
+str(case0102)   
 
 boxplot(Salary ~ Sex, 
   ylab= "Starting Salary (U.S. Dollars)", 

Modified: pkg/Sleuth3/man/case0201.Rd
===================================================================
--- pkg/Sleuth3/man/case0201.Rd	2012-07-24 16:20:24 UTC (rev 36)
+++ pkg/Sleuth3/man/case0201.Rd	2012-08-03 16:26:35 UTC (rev 37)
@@ -26,12 +26,12 @@
 }
 
 \source{
-  Ramsey, F.L. and Schafer, D.W. (2012). \emph{The Statistical Sleuth: A
-    Course in Methods of Data Analysis (3rd ed)}, Duxbury.
+  Ramsey, F.L. and Schafer, D.W. (2013). \emph{The Statistical Sleuth: A
+    Course in Methods of Data Analysis (3rd ed)}, Cengage Learning.
 }
 
 \references{
-  Grant, P. (1986). \bold{Ecology and Evolution of Darwin's Finches},
+  Grant, P. (1986). \emph{Ecology and Evolution of Darwin's Finches},
   Princeton University Press, Princeton, N.J. 
 }
 
@@ -45,9 +45,11 @@
                                          
 mean(Depth[Year==1978]) - mean(Depth[Year==1976])  
 
-yearFactor <- factor(Year) 
-t.test(Depth ~ yearFactor, var.equal=TRUE)  
-t.test(Depth ~ yearFactor, var.equal=TRUE, alternative = "less") 
+yearFactor <- factor(Year) # Convert the numerical variable Year into a factor
+# with 2 levels. 1976 is "group 1" (it comes first alphanumerically)
+t.test(Depth ~ yearFactor, var.equal=TRUE) # 2-sample t-test; 2-sided by default 
+t.test(Depth ~ yearFactor, var.equal=TRUE, 
+  alternative = "less") # 1-sided; alternative: group 1 mean is less 
 
 boxplot(Depth ~ Year,  
   ylab= "Beak Depth (mm)",   
@@ -56,20 +58,10 @@
 
 ## BOXPLOTS FOR PRESENTATION
 boxplot(Depth ~ Year,             
-        ylab="Beak Depth (mm)",  
-        names=c("89 Finches in 1976","89 Finches in 1978"),  
-        main="Beak Depths of Darwin Finches in 1976 and 1978",
-        col="green", 
-        boxlwd=2,   
-        medlwd=2, 
-        whisklty=1, 
-        whisklwd=2, 
-        staplewex=.2, 
-        staplelwd=2,  
-        outlwd=2, 
-        outpch=21,
-        outbg="green", 
-        outcex=1.5)       
+  ylab="Beak Depth (mm)", names=c("89 Finches in 1976","89 Finches in 1978"),  
+  main="Beak Depths of Darwin Finches in 1976 and 1978", col="green", 
+  boxlwd=2, medlwd=2, whisklty=1, whisklwd=2, staplewex=.2, staplelwd=2,  
+  outlwd=2, outpch=21, outbg="green", outcex=1.5)       
         
 detach(case0201)  
 }

Modified: pkg/Sleuth3/man/case0202.Rd
===================================================================
--- pkg/Sleuth3/man/case0202.Rd	2012-07-24 16:20:24 UTC (rev 36)
+++ pkg/Sleuth3/man/case0202.Rd	2012-08-03 16:26:35 UTC (rev 37)
@@ -8,7 +8,7 @@
   controlled for genetic and socioeconomic differences by examining 15
   pairs of monozygotic twins, where one of the twins was schizophrenic
   and the other was not.  The researchers used magnetic resonance
-  imaging to measure the volumes (in cm$^3$) of several regions and
+  imaging to measure the volumes (in cm\eqn{^3}) of several regions and
   subregions of the twins' brains.
 }
 \usage{case0202}
@@ -22,8 +22,8 @@
   }
 }
 \source{
-  Ramsey, F.L. and Schafer, D.W. (2012). \emph{The Statistical Sleuth: A
-    Course in Methods of Data Analysis (3rd ed)}, Duxbury.
+  Ramsey, F.L. and Schafer, D.W. (2013). \emph{The Statistical Sleuth: A
+    Course in Methods of Data Analysis (3rd ed)}, Cengage Learning.
 }
 \references{
   Suddath, R.L., Christison, G.W., Torrey, E.F., Casanova, M.F. and
@@ -38,30 +38,22 @@
 diff <- Unaffected-Affected    
 summary(diff)
 t.test(diff) # Paired t-test is a one-sample t-test on differnces 
-t.test(Unaffected,Affected,pair=TRUE)   # same thing 
+t.test(Unaffected,Affected,pair=TRUE)  # Alternative coding for the same test 
 
 boxplot(diff,       
-        ylab="Difference in Hippocampus Volume (cubic cm)", 
-        xlab="15 Sets of Twins, One Affected with Schizophrenia", 
-        main="Hippocampus Difference: Unaffected Twin Minus Affected Twin") 
+  ylab="Difference in Hippocampus Volume (cubic cm)", 
+  xlab="15 Sets of Twins, One Affected with Schizophrenia", 
+  main="Hippocampus Difference: Unaffected Twin Minus Affected Twin") 
 abline(h=0,lty=2)   # Draw a dashed (lty=2) horizontal line at 0    
   
 ## BOXPLOT FOR PRESENTATION:
 boxplot(diff, 
-        ylab="Difference in Hippocampus Volume (cubic cm)", 
-        xlab="15 Sets of Twins, One Affected with Schizophrenia",
-        main="Hippocampus Difference: Unaffected Minus Affected Twin",  
-        col="green",  
-        boxlwd=2, 
-        medlwd=2, 
-        whisklty=1,
-        whisklwd=2,  
-        staplewex=.2, 
-        staplelwd=2, 
-        outlwd=2, 
-        outpch=21,
-        outbg="green",
-        outcex=1.5)      
+  ylab="Difference in Hippocampus Volume (cubic cm)", 
+  xlab="15 Sets of Twins, One Affected with Schizophrenia",
+  main="Hippocampus Difference: Unaffected Minus Affected Twin",  
+  col="green", boxlwd=2, medlwd=2, whisklty=1, whisklwd=2, 
+  staplewex=.2, staplelwd=2, outlwd=2, outpch=21, outbg="green",
+  outcex=1.5)      
 abline(h=0,lty=2) 
 
 detach(case0202)  

Modified: pkg/Sleuth3/man/case0301.Rd
===================================================================
--- pkg/Sleuth3/man/case0301.Rd	2012-07-24 16:20:24 UTC (rev 36)
+++ pkg/Sleuth3/man/case0301.Rd	2012-08-03 16:26:35 UTC (rev 37)
@@ -20,8 +20,8 @@
   }
 }
 \source{
-  Ramsey, F.L. and Schafer, D.W. (2012). \emph{The Statistical Sleuth: A
-    Course in Methods of Data Analysis (3rd ed)}, Duxbury.
+  Ramsey, F.L. and Schafer, D.W. (2013). \emph{The Statistical Sleuth: A
+    Course in Methods of Data Analysis (3rd ed)}, Cengage Learning.
 }
 \references{
 Simpson, J., Olsen, A., and Eden, J. (1975). A Bayesian Analysis of a
@@ -30,15 +30,17 @@
 }
 \examples{
 attach(case0301) 
-str(case0301)
+str(case0301) #Seeded is level 1 of Treatment (it's first alphabetically)
 
 boxplot(Rainfall ~ Treatment) 
-boxplot(log(Rainfall) ~ Treatment)  
+boxplot(log(Rainfall) ~ Treatment) # Boxplots of natural logs of Rainfall 
 
-t.test(log(Rainfall) ~ Treatment, alternative="greater", var.equal=TRUE)
+t.test(log(Rainfall) ~ Treatment, var.equal=TRUE,
+  alternative="greater") # 1-sided t-test; alternative: level 1 mean is greater
         
-# Use 2-sided alternative to get a 2-sided confidence interval:
-myTest <- t.test(log(Rainfall) ~ Treatment, alternative="two.sided", var.equal=TRUE) 
+
+myTest <- t.test(log(Rainfall) ~ Treatment,  var.equal=TRUE,
+  alternative="two.sided") # 2-sided alternative to get confidence interval
 exp(myTest$est[1] - myTest$est[2])  # Back-transform estimate on log scale 
 exp(myTest$conf) # Back transform endpoints of confidence interval 
 
@@ -48,25 +50,17 @@
   main="Distributions of Rainfalls from Cloud Seeding Experiment") 
 
 ## POLISHED BOXPLOTS FOR PRESENTATION:
-par(mar=c(4,4,4,4))
-boxplot(log(Rainfall) ~ Treatment, 
-        ylab="Log Rainfall (Acre-Feet)",
-        names=c("on 26 seeded days","on 26 unseeded days"), 
-        main="Boxplots of Rainfall on Log Scale",
-        col="green", 
-        boxlwd=2,
-        medlwd=2, 
-        whisklty=1, 
-        whisklwd=2,
-        staplewex=.2, 
-        staplelwd=2,
-        outlwd=2, 
-        outpch=21, 
-        outbg="green",  
-        outcex=1.5      )        
-myTicks <- c(1,5,10,100,500,1000,2000,3000) # Create some tick marks for original scale 
+opar <- par(no.readonly=TRUE)  # Store device graphics parameters
+par(mar=c(4,4,4,4))   # Change margins to allow more space on right
+boxplot(log(Rainfall) ~ Treatment, ylab="Log Rainfall (Acre-Feet)",
+  names=c("on 26 seeded days","on 26 unseeded days"), 
+  main="Boxplots of Rainfall on Log Scale", col="green", boxlwd=2,
+  medlwd=2, whisklty=1, whisklwd=2, staplewex=.2, staplelwd=2,
+  outlwd=2, outpch=21, outbg="green", outcex=1.5      )        
+myTicks <- c(1,5,10,100,500,1000,2000,3000) # some tick marks for original scale 
 axis(4, at=log(myTicks), label=myTicks)   # Add original-scale axis on right    
 mtext("Rainfall (Acre Feet)", side=4, line=2.5) # Add right-side axis label 
+par(opar)  # Restore previous graphics parameter settings
 
 detach(case0301) 
 }

Modified: pkg/Sleuth3/man/case0302.Rd
===================================================================
--- pkg/Sleuth3/man/case0302.Rd	2012-07-24 16:20:24 UTC (rev 36)
+++ pkg/Sleuth3/man/case0302.Rd	2012-08-03 16:26:35 UTC (rev 37)
@@ -19,8 +19,8 @@
   }
 }
 \source{
-  Ramsey, F.L. and Schafer, D.W. (2012). \emph{The Statistical Sleuth: A
-    Course in Methods of Data Analysis (3rd ed)}, Duxbury.
+  Ramsey, F.L. and Schafer, D.W. (2013). \emph{The Statistical Sleuth: A
+    Course in Methods of Data Analysis (3rd ed)}, Cengage Learning.
 }
 \references{
   Centers for Disease Control Veterans Health Studies: Serum
@@ -30,27 +30,35 @@
 }
 \examples{
 attach(case0302)  
-str(case0302) 
+str(case0302)    # Note: Level 1 of Veteran is "Other" (first alphabeticall)
+
 boxplot(Dioxin ~ Veteran)  
 
-t.test(Dioxin ~ Veteran, alternative="less", var.equal=TRUE)  
-t.test(Dioxin ~ Veteran, alternative="less", var.equal=TRUE, subset=(Dioxin < 40))  
-t.test(Dioxin ~ Veteran, alternative="less", var.equal=TRUE, subset=(Dioxin < 20))    
-t.test(Dioxin ~ Veteran, var.equal=TRUE)  
+t.test(Dioxin ~ Veteran, var.equal=TRUE,
+  alternative="less") # 1-sided t-test; alternative: group 1 mean is less  
+t.test(Dioxin ~ Veteran, alternative="less", var.equal=TRUE, 
+  subset=(Dioxin < 40)) # t-test on subset for which Dioxin < 40  
+t.test(Dioxin ~ Veteran, alternative="less", var.equal=TRUE, 
+  subset=(Dioxin < 20))    
+t.test(Dioxin ~ Veteran, var.equal=TRUE) # 2-sided--to get confidence interval 
 
 ## HISTOGRAMS FOR PRESENTATION  
-par(mfrow=c(2,1), mar=c(3,3,1,1))     
+opar <- par(no.readonly=TRUE)  # Store device graphics parameter settings
+par(mfrow=c(2,1), mar=c(3,3,1,1)) # 2 by 1 layout of plots; change margins    
 myBreaks <- (0:46) - .5    # Make breaks for histogram bins  
 hist(Dioxin[Veteran=="Other"], breaks=myBreaks, xlim=range(Dioxin),
-     col="green", xlab="", ylab="", main="")     
-text(10,25, "Dioxin in 97 'Other' Veterans; Estimated mean =  4.19 ppt (95 pct CI: 3.72 to 4.65 ppt)",
-     pos=4, cex=.75)     
+  col="green", xlab="", ylab="", main="")     
+text(10,25, 
+  "Dioxin in 97 'Other' Veterans; Estimated mean =  4.19 ppt (95\% CI: 3.72 to 4.65 ppt)",
+  pos=4, cex=.75) # CI from 1-sample t-test & subset=(Veteran="Other")    
 hist(Dioxin[Veteran=="Vietnam"],breaks=myBreaks,xlim=range(Dioxin),
-     col="green", xlab="", ylab="", main="")   
-text(10,160,"Dioxin in 646 Vietnam Veterans; Estimated mean =  4.26 ppt (95 pct CI: 4.06 to 4.64 ppt)",
-     pos=4, cex=.75)   
-text(13,145,"[Estimated Difference in Means: 0.07 ppt (95 pct CI: -0.63 to 0.48 ppt])",
-     pos=4, cex=.75)  
+  col="green", xlab="", ylab="", main="")   
+text(10,160,
+  "Dioxin in 646 Vietnam Veterans; Estimated mean =  4.26 ppt (95\% CI: 4.06 to 4.64 ppt)",
+  pos=4, cex=.75)   
+text(13,145,"[Estimated Difference in Means: 0.07 ppt (95\% CI: -0.63 to 0.48 ppt)]",
+  pos=4, cex=.75)  
+par(opar) # Restore previous graphics parameter settings
   
 detach(case0302)    
 }

Modified: pkg/Sleuth3/man/case0401.Rd
===================================================================
--- pkg/Sleuth3/man/case0401.Rd	2012-07-24 16:20:24 UTC (rev 36)
+++ pkg/Sleuth3/man/case0401.Rd	2012-08-03 16:26:35 UTC (rev 37)
@@ -18,8 +18,8 @@
   }
 }
 \source{
-  Ramsey, F.L. and Schafer, D.W. (2012). \emph{The Statistical Sleuth: A
-    Course in Methods of Data Analysis (3rd ed)}, Duxbury.
+  Ramsey, F.L. and Schafer, D.W. (2013). \emph{The Statistical Sleuth: A
+    Course in Methods of Data Analysis (3rd ed)}, Cengage Learning.
 }
 \references{
   Feynman, R.P. (1988).  \emph{What do You Care What Other People
@@ -35,29 +35,26 @@
 mCool <- mean(Incidents[Launch=="Cool"]) 
 mWarm <- mean(Incidents[Launch=="Warm"])
 mDiff <- mCool - mWarm
-c(mCool,mWarm,mDiff)
+c(mCool,mWarm,mDiff)  # Show the values of these variables
 
-## PERMUTATION TEST BASED ON DIFFERENCE IN AVERAGES, VIA REPEATED RANDOM RE-GROUPING (ADVANCED)
-numRep  <- 50 # Number of random re-groupings.
-              # NOTE: this should be changed to something like 50,000 for useful results.
-rDiff   <- rep(0,numRep) # A place to store the differences in averages from the re-groupings
-for (rep in 1:numRep) {  # Repeat the commands following numRep times
-  randomGroup <- rep("rWarm",24)  # Initially set this to 24 values "rWarm"
-  randomGroup[sample(1:24,4)]  <- "rCool"  # Replace 4 and random with "rCool"
-  mW  <- mean(Incidents[randomGroup=="rWarm"])
-  mC  <- mean(Incidents[randomGroup=="rCool"])
-  rDiff[rep] <- mC-mW  # Store the difference in averages
-                                }
-hist(rDiff,     # Draw a histogram of the difference in averages from numRep random re-groupings
+## PERMUTATION TEST , VIA REPEATED RANDOM RE-GROUPING (ADVANCED)
+numRep  <- 50 # Number of random  groupings. CHANGE TO LARGER NUMBER; eg 50,000.   
+rDiff   <- rep(0,numRep) # Initialize this variable to contain numRep 0s.
+for (rep in 1:numRep) {  # Repeat the following commands numRep times:
+  randomGroup <- rep("rWarm",24)  # Set randomGroup to have 24 values "rWarm"
+  randomGroup[sample(1:24,4)]  <- "rCool"  # Replace 4 at random with "rCool"
+  mW  <- mean(Incidents[randomGroup=="rWarm"]) # average of random "rWarm" group
+  mC  <- mean(Incidents[randomGroup=="rCool"]) # average of random "rCool" group
+  rDiff[rep] <- mC-mW  # Store difference in averages in 'rep' cell of rDiff
+           }  # End of loop
+hist(rDiff,  # Histogram of difference in averages from numRep random groupings
   main="Approximate Permutation Distribution",
   xlab="Possible Values of Difference in Averages",
   ylab="Frequency of Occurrence")
-abline(v=mDiff)  # Make a vertical line at the actually observed difference
-pValue <- sum(rDiff >= 1.3)/numRep  # 1-sided p-value = proportion of re-groupings with diff >= observed
+abline(v=mDiff)  # Draw a vertical line at the actually observed difference
+pValue <- sum(rDiff >= 1.3)/numRep  # 1-sided p-value
 pValue  
-text(mDiff,75000, 
-  paste(" -->",round(pValue,4)),  
-  adj=-0.1) 
+text(mDiff,75000, paste(" -->",round(pValue,4)), adj=-0.1) 
 
 detach(case0401) 
 }

Modified: pkg/Sleuth3/man/case0402.Rd
===================================================================
--- pkg/Sleuth3/man/case0402.Rd	2012-07-24 16:20:24 UTC (rev 36)
+++ pkg/Sleuth3/man/case0402.Rd	2012-08-03 16:26:35 UTC (rev 37)
@@ -22,8 +22,8 @@
   }
 }
 \source{
-  Ramsey, F.L. and Schafer, D.W. (2012). \emph{The Statistical Sleuth: A
-    Course in Methods of Data Analysis (3rd ed)}, Duxbury.
+  Ramsey, F.L. and Schafer, D.W. (2013). \emph{The Statistical Sleuth: A
+    Course in Methods of Data Analysis (3rd ed)}, Cengage Learning.
 }
 \references{
   Sweller, J., Chandler, P., Tierney, P. and Cooper, M. (1990).
@@ -32,24 +32,27 @@
   176--192. 
 }
 \examples{
-str(case0402)  
+str(case0402) # level 1 of Treatment is "Conventional" (1st alphabetically)
 attach(case0402)  
 
 boxplot(Time ~ Treatment) 
 median(Time[Treatment=="Conventional"])-median(Time[Treatment=="Modified"])  
   
-wilcox.test(Time ~ Treatment, exact=FALSE, correct=TRUE, alternative="greater") 
-wilcox.test(Time ~ Treatment, exact=FALSE, correct=TRUE, alternative="two.sided", conf.int=TRUE)    
+wilcox.test(Time ~ Treatment, exact=FALSE, correct=TRUE, 
+  alternative="greater")  # Rank-sum test; alternative: group 1 is greater
+wilcox.test(Time ~ Treatment, exact=FALSE, correct=TRUE, 
+  alternative="two.sided", conf.int=TRUE)  # Use 2-sided to get confidence int.  
         
 ## DOT PLOTS FOR PRESENTATION 
-xTreatment    <- ifelse(Treatment=="Conventional",1,2)  
+xTreatment    <- ifelse(Treatment=="Conventional",1,2) # Make numerical values  
 myPointCode   <- ifelse(Censored==0,21,24)  
-plot(Time ~ jitter(xTreatment,.2),
-     ylab="Completion Time (Sec.)",  xlab="Training Method (jittered for visibility)",
+plot(Time ~ jitter(xTreatment,.2),   # Jitter the 1's and 2's for visibility
+     ylab="Completion Time (Sec.)",  xlab="Training Method (jittered)",
      main="Test Completion Times from Cognitive Load Experiment",
      axes=FALSE, pch=myPointCode, bg="green", cex=2, xlim=c(.5,2.5) )  
-axis(2) 
-axis(1, tick=FALSE,  at=c(1,2),  labels=c("Conventional (n=14 Students)","Modified (n=14 Students)") )  
+axis(2) # Draw y-axis as usual
+axis(1, tick=FALSE,  at=c(1,2),  # Draw x-axis without ticks
+  labels=c("Conventional (n=14 Students)","Modified (n=14 Students)") )  
 legend(1.5,300, legend=c("Did not Complete in 300 sec","Completed in 300 sec."),
        pch=c(24,21), pt.cex=2, pt.bg="green")  
   

Modified: pkg/Sleuth3/man/case0501.Rd
===================================================================
--- pkg/Sleuth3/man/case0501.Rd	2012-07-24 16:20:24 UTC (rev 36)
+++ pkg/Sleuth3/man/case0501.Rd	2012-08-03 16:26:35 UTC (rev 37)
@@ -33,8 +33,8 @@
   }
 }
 \source{
-  Ramsey, F.L. and Schafer, D.W. (2012). \emph{The Statistical Sleuth: A
-    Course in Methods of Data Analysis (3rd ed)}, Duxbury.
+  Ramsey, F.L. and Schafer, D.W. (2013). \emph{The Statistical Sleuth: A
+    Course in Methods of Data Analysis (3rd ed)}, Cengage Learning.
 }
 \references{
    Weindruch, R., Walford, R.L., Fligiel, S. and Guthrie D. (1986). The
@@ -46,15 +46,19 @@
 str(case0501)
 attach(case0501)
 
-myDiet  <- factor(Diet, levels=c("NP","N/N85","N/R50","R/R50","lopro","N/R40") )  # Re-order levels for better boxplot ordering 
-myNames <- c("NP(49)","N/N85(57)","N/R50(71)","R/R50(56)","lopro(56)","N/R40(60)")
-boxplot(Lifetime ~ myDiet, ylab= "Lifetime (months)", names=myNames, xlab="Treatment (and sample size)") 
-myAov1   <- aov(Lifetime ~ Diet)
-plot(myAov1, which=1) 
+# Re-order levels for better boxplot organization: 
+myDiet  <- factor(Diet, levels=c("NP","N/N85","N/R50","R/R50","lopro","N/R40") ) 
+ 
+myNames <- c("NP(49)","N/N85(57)","N/R50(71)","R/R50(56)","lopro(56)",
+  "N/R40(60)")   # Make these for boxplot labeling.
+boxplot(Lifetime ~ myDiet, ylab= "Lifetime (months)", names=myNames, 
+  xlab="Treatment (and sample size)") 
+myAov1   <- aov(Lifetime ~ Diet) # One-way analysis of variance
+plot(myAov1, which=1) # Plot residuals versus estimated means.
 summary(myAov1) 
-pairwise.t.test(Lifetime,Diet, pool.SD=TRUE, p.adj="none") 
+pairwise.t.test(Lifetime,Diet, pool.SD=TRUE, p.adj="none") # All t-tests
 
-## p-VALUES AND CONFIDENCE INTERVALS FOR SPECIFIED COMPARISONS OF MEANS, USING GLHT IN MULTCOMP PACKAGE
+## p-VALUES AND CONFIDENCE INTERVALS FOR SPECIFIED COMPARISONS OF MEANS
 if(require(multcomp)){
   diet    <- factor(Diet,labels=c("lopro", "NN85", "NR40", "NR50", "NP", "RR50")) 
   myAov2  <- aov(Lifetime ~ diet - 1) 
@@ -64,16 +68,16 @@
           "dietRR50  - dietNR50 = 0",
           "dietlopro - dietNR50 = 0",
           "dietNN85  - dietNP   = 0")   ) 
-  summary(myComparisons,test=adjusted("none"))      # No multiple comparison adjustment (for these planned comparisons)
-  confint(myComparisons, calpha = univariate_calpha()) # No multiple comparison adjustment
-}
+  summary(myComparisons,test=adjusted("none")) # No multiple comparison adjust.
+  confint(myComparisons, calpha = univariate_calpha()) # No adjustment
+ }
 
 ## EXAMPLE 5: BOXPLOTS FOR PRESENTATION  
 boxplot(Lifetime ~ myDiet, ylab= "Lifetime (months)", names=myNames,
-        main= "Lifetimes of Mice on 6 Diet Regimens",
-        xlab="Diet (and sample size)", col="green", boxlwd=2, medlwd=2,
-        whisklty=1, whisklwd=2, staplewex=.2, staplelwd=2, outlwd=2,
-        outpch=21, outbg="green", outcex=1.5)   
+  main= "Lifetimes of Mice on 6 Diet Regimens",
+  xlab="Diet (and sample size)", col="green", boxlwd=2, medlwd=2, whisklty=1, 
+  whisklwd=2, staplewex=.2, staplelwd=2, outlwd=2, outpch=21, outbg="green", 
+  outcex=1.5)   
                 
 detach(case0501)
 

Modified: pkg/Sleuth3/man/case0502.Rd
===================================================================
--- pkg/Sleuth3/man/case0502.Rd	2012-07-24 16:20:24 UTC (rev 36)
+++ pkg/Sleuth3/man/case0502.Rd	2012-08-03 16:26:35 UTC (rev 37)
@@ -24,13 +24,13 @@
   \describe{
     \item{\code{Percent}}{is the percent of women on the venire's of the Spock
       trial judge and 6 other Boston area judges} 
-    \item{\code{Judge}}{a factor with levels \code{"Spock's"}, \code{"A"},
+    \item{\code{Judge}}{is a factor with levels \code{"Spock's"}, \code{"A"},
       \code{"B"}, \code{"C"}, \code{"D"}, \code{"E"} and \code{"F"}} 
   }
 }
 \source{
-  Ramsey, F.L. and Schafer, D.W. (2012). \emph{The Statistical Sleuth: A
-    Course in Methods of Data Analysis (3rd ed)}, Duxbury.
+  Ramsey, F.L. and Schafer, D.W. (2013). \emph{The Statistical Sleuth: A
+    Course in Methods of Data Analysis (3rd ed)}, Cengage Learning.
 }
 \references{
   Zeisel, H. and Kalven, H. Jr. (1972).  Parking Tickets and Missing
@@ -41,27 +41,29 @@
 str(case0502)  
 attach(case0502) 
 
-myNames  <- c("A (5)", "B (6)", "C (9)", "D (2)", "E (6)", "F (9)", "Spock's (9)" )  # Factor level names (with sample sizes) for boxplots
+# Make new factor level names (with sample sizes) for boxplots
+myNames <- c("A (5)", "B (6)", "C (9)", "D (2)", "E (6)", "F (9)", "Spock's (9)")
+  
 boxplot(Percent ~ Judge, ylab = "Percent of Women on Judges' Venires",
-        names = myNames, xlab = "Judge (and number of venires)",
-        main = "Percent Women on Venires of 7 Massachusetts Judges") 
+  names = myNames, xlab = "Judge (and number of venires)",
+  main = "Percent Women on Venires of 7 Massachusetts Judges") 
 myAov1  <- aov(Percent ~ Judge)  
 plot(myAov1, which=1)   # Residual plot
-summary(myAov1) # Initial screening--is there evidence that any means differ from any others?  (Yes)
+summary(myAov1) # Initial screening. Any evidence of judge differences? (yes)
    
 ## ANALYSIS 1. TWO-SAMPLE t-TEST (ASSUMING NON-SPOCK JUDGES HAVE A COMMON MEAN)
-SpockOrOther <- factor(ifelse(Judge=="Spock's","Spock","Other"))   # Indicator for Spock's judge                                 
+SpockOrOther <- factor(ifelse(Judge=="Spock's","Spock","Other"))                                   
 aovFull      <- aov(Percent ~ Judge) 
 aovReduced   <- aov(Percent ~ SpockOrOther) 
-anova(aovReduced,aovFull)  # Is there evidence that the 7 mean model fits better than the 2 mean model? (No)     
-t.test(Percent ~ SpockOrOther, var.equal=TRUE) # Is there evidence in the 2 mean model that the means differ? (Yes)
+anova(aovReduced,aovFull) #Any evidence that 7 mean fits better than the 2 mean?       
+t.test(Percent ~ SpockOrOther, var.equal=TRUE) # Evidence that 2 means differ?  
 
-## ANALYSIS 2. COMPARE SPOCK MEAN TO AVERAGE OF OTHER MEANS (NOT ASSUMING NON-SPOCK JUDGES HAVE A COMMON MEAN)
-if(require(multcomp)){
+## ANALYSIS 2. COMPARE SPOCK MEAN TO AVERAGE OF OTHER MEANS 
   myAov3        <- aov(Percent ~ Judge - 1) 
-  myContrast    <- rbind(c(1/6, 1/6, 1/6, 1/6, 1/6, 1/6, - 1)) 
+  myContrast    <- rbind(c(1/6, 1/6, 1/6, 1/6, 1/6, 1/6, - 1))
+if(require(multcomp)){  # use multcomp library
   myComparison  <- glht(myAov3, linfct=myContrast) 
-  summary(myComparison, test=adjusted("none"))   # Is there evidence that Spock mean differs from average of other 6? (Yes)
+  summary(myComparison, test=adjusted("none"))   
   confint(myComparison) 
 }
 

Added: pkg/Sleuth3/man/case0601.Rd
===================================================================
--- pkg/Sleuth3/man/case0601.Rd	                        (rev 0)
+++ pkg/Sleuth3/man/case0601.Rd	2012-08-03 16:26:35 UTC (rev 37)
@@ -0,0 +1,87 @@
+\name{case0601}
+\alias{case0601}
+\docType{data}
+\title{Discrimination Against the Handicapped}
+\description{
+  Study explores how physical handicaps affect people's perception of
+  employment qualifications.  Researchers prepared 5 videotaped job
+  interviews using actors with a script designed to reflect an interview
+  with an applicant of average qualifications.  The 5 tapes differed
+  only in that the applicant appeared with a different handicap in each
+  one.  Seventy undergraduate students were randomly assigned to view
+  the tapes and rate the qualification of the applicant on a 0-10 point
+  scale. 
+}
+\usage{case0601}
+\format{
+  A data frame with 70 observations on the following 2 variables.
+  \describe{
+    \item{\code{Score}}{is the score each student gave to the applicant}
+    \item{\code{Handicap}}{is a factor variable with 5
+      levels---\code{"None"}, \code{"Amputee"}, \code{"Crutches"},
+      \code{"Hearing"} and  \code{"Wheelchair"}} 
+  }
+}
+\source{
+  Ramsey, F.L. and Schafer, D.W. (2013). \emph{The Statistical Sleuth: A
+    Course in Methods of Data Analysis (3rd ed)}, Cengage Learning.
+}
+\references{
+  Cesare, S.J., Tannenbaum, R.J. and Dalessio, A. (1990). Interviewers'
+  Decisions Related to Applicant Handicap Type and Rater Empathy, \emph{Human
+  Performance} \bold{3}(3): 157--171. 
+}
+\examples{
+str(case0601) 
+attach(case0601) 
+
+## EXPLORATION
+myHandicap  <- factor(Handicap,  
+  levels=c("None","Amputee","Crutches","Hearing","Wheelchair"))  
+boxplot(Score ~ myHandicap, 
+  ylab= "Qualification Score Assigned by Student to Interviewee",  
+  xlab= "Treatment Group--Handicap Portrayed (14 Students in each Group)", 
+  main= "Handicap Discrimination Experiment on 70 Undergraduate Students") 
+myAov  <- aov(Score ~ myHandicap) 
+plot(myAov, which=1) # Plot residuals versus estimated means 
+summary(myAov) 
+
+## COMPARE MEAN QUALIFICATION SCORE OF EVERY HANDICAP GROUP TO "NONE"  
+if(require(multcomp)){     # Use the multcomp library
+  myDunnett  <- glht(myAov, linfct = mcp(myHandicap = "Dunnett"))  
+  summary(myDunnett) 
+  confint(myDunnett,level=.95) 
+  opar <- par(no.readonly=TRUE)  # Save current graphics parameter settings
+  par(mar=c(4.1,8.1,4.1,1.1)) # Change margins 
+  plot(myDunnett, 
+    xlab="Difference in Mean Qualification Score (and Dunnet-adjusted CIs)") 
+  par(opar)  # Restore original graphics parameter settings
+}
+
+## COMPARE EVERY MEAN TO EVERY OTHER MEAN
+if(require(multcomp)){   # Use the multcomp library
+  myTukey   <- glht(myAov, linfct = mcp(myHandicap = "Tukey"))  
+summary(myTukey) 
+}
+
+## TEST THE CONTRAST OF DISPLAY 6.4
+myAov2        <- aov(Score ~ myHandicap - 1)    
+myContrast    <- rbind(c(0, -1/2, 1/2, -1/2, 1/2)) 
+if(require(multcomp)){   # Use the multcomp library
+  myComparison  <- glht(myAov2, linfct=myContrast)
+  summary(myComparison, test=adjusted("none"))  
+  confint(myComparison)  
+}  
+
+
+# BOXPLOTS FOR PRESENTATION   
+boxplot(Score ~ myHandicap, 
+  ylab= "Qualification Score Assigned by Student to Video Job Applicant",  
+  xlab="Handicap Portrayed by Job Applicant in Video (14 Students in each Group)",  
+  main= "Handicap Discrimination Experiment on 70 Undergraduate Students", 
+  col="green", boxlwd=2, medlwd=2, whisklty=1, whisklwd=2, staplewex=.2,  
+	staplelwd=2, outlwd=2, outpch=21,  outbg="green", outcex=1.5) 
+	
+detach(case0601) 
+}
+\keyword{datasets}


Property changes on: pkg/Sleuth3/man/case0601.Rd
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:eol-style
   + native

Added: pkg/Sleuth3/man/case0602.Rd
===================================================================
--- pkg/Sleuth3/man/case0602.Rd	                        (rev 0)
+++ pkg/Sleuth3/man/case0602.Rd	2012-08-03 16:26:35 UTC (rev 37)
@@ -0,0 +1,79 @@
+\name{case0602}
+\alias{case0602}
+\docType{data}
+\title{Mate Preference of Platyfish}
+\description{
+  Do female Platyfish prefer male Platyfish with yellow swordtails?
+  A.L. Basolo proposed and tested a selection model in which females
+  have a pre-existing bias for a male trait even before the males
+  possess it.  Six pairs of males were surgically given artificial,
+  plastic swordtails---one pair received a bright yellow sword, the other
+  a transparent sword.  Females were given the opportunity to engage in
+  courtship activity with either of the males.  Of the total time spent
+  by each female engaged in courtship during a 20 minute observation
+  period, the percentages of time spent with the yellow-sword male were
+  recorded. 
+}
+\usage{case0602}
+\format{
+  A data frame with 84 observations on the following 3 variables.
+  \describe{
+    \item{\code{Proportion}}{The proportion of courtship time spent by 84
+      females with the yellow-sword males} 
+    \item{\code{Pair}}{Factor variable with 6 levels---\code{"Pair1"},
+      \code{"Pair2"}, \code{"Pair3"}, \code{"Pair4"}, \code{"Pair5"} and
+      \code{"Pair6"}} 
+    \item{\code{Length}}{Body size of the males}
+  }
+}
+\source{
+  Ramsey, F.L. and Schafer, D.W. (2013). \emph{The Statistical Sleuth: A
+    Course in Methods of Data Analysis (3rd ed)}, Cengage Learning.
+}
+\references{
+  Basolo, A.L. (1990).  Female Preference Predates the Evolution of the
+  Sword in Swordtail Fish, \emph{Science} \bold{250}: 808--810.  
+}
+\examples{
+str(case0602)  
+attach(case0602)   
+
+## EXPLORATION
+plot(Proportion ~ Length,  
+  xlab="Length of the Two Males",  
+  ylab="Proportion of Time Female Spent with Yellow-Sword Male",  
+  main="Proportion of Time Spent with Yellow Rather than Transparent Sword Male") 
[TRUNCATED]

To get the complete diff run:
    svnlook diff /svnroot/sleuth2 -r 37


More information about the Sleuth2-commits mailing list