library(tidyverse)
## Warning: package 'tidyverse' was built under R version 4.0.2
## -- Attaching packages --------------------------------------- tidyverse 1.3.0 --
## v ggplot2 3.3.2     v purrr   0.3.4
## v tibble  3.0.4     v dplyr   1.0.2
## v tidyr   1.1.2     v stringr 1.4.0
## v readr   1.4.0     v forcats 0.5.0
## Warning: package 'tibble' was built under R version 4.0.3
## Warning: package 'tidyr' was built under R version 4.0.2
## Warning: package 'dplyr' was built under R version 4.0.2
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
library(infer)
## Warning: package 'infer' was built under R version 4.0.2
library(mosaic)
## Warning: package 'mosaic' was built under R version 4.0.2
## Registered S3 method overwritten by 'mosaic':
##   method                           from   
##   fortify.SpatialPolygonsDataFrame ggplot2
## 
## The 'mosaic' package masks several functions from core packages in order to add 
## additional features.  The original behavior of these functions should not be affected by this.
## 
## Attaching package: 'mosaic'
## The following object is masked from 'package:Matrix':
## 
##     mean
## The following objects are masked from 'package:infer':
## 
##     prop_test, t_test
## The following objects are masked from 'package:dplyr':
## 
##     count, do, tally
## The following object is masked from 'package:purrr':
## 
##     cross
## The following object is masked from 'package:ggplot2':
## 
##     stat
## The following objects are masked from 'package:stats':
## 
##     binom.test, cor, cor.test, cov, fivenum, IQR, median, prop.test,
##     quantile, sd, t.test, var
## The following objects are masked from 'package:base':
## 
##     max, mean, min, prod, range, sample, sum
library(openintro)
## Warning: package 'openintro' was built under R version 4.0.2
## Loading required package: airports
## Warning: package 'airports' was built under R version 4.0.2
## Loading required package: cherryblossom
## Warning: package 'cherryblossom' was built under R version 4.0.2
## Loading required package: usdata
## Warning: package 'usdata' was built under R version 4.0.2
## 
## Attaching package: 'openintro'
## The following object is masked from 'package:mosaic':
## 
##     dotPlot
## The following objects are masked from 'package:lattice':
## 
##     ethanol, lsegments
library(BSDA)
## Warning: package 'BSDA' was built under R version 4.0.3
## 
## Attaching package: 'BSDA'
## The following object is masked from 'package:mosaic':
## 
##     CIsim
## The following object is masked from 'package:mosaicData':
## 
##     Alcohol
## The following object is masked from 'package:datasets':
## 
##     Orange
getwd()
## [1] "C:/Users/Jerome/Documents/From_Toshiba_HD_Work_Files/0000_Montgomery_College/Math_217/Exam_2"
wheatstem = c(2.3, 2.6, 2.4, 2.2, 2.3, 2.5,2.0, 1.9 )

mean(wheatstem)
## [1] 2.275
sd(wheatstem)
## [1] 0.237547
hist(wheatstem)

Construct the 95% CI

meanws = mean(wheatstem)
s  = sd(wheatstem)
stderr = s/sqrt(8)
E = qt(.975, df = 8-1)*stderr
meanws + c(-E,E)
## [1] 2.076406 2.473594
print(meanws)
## [1] 2.275
print(stderr)
## [1] 0.08398554

Question 6.S.16

nUse <- R-Code to solve this: monarch 3 / , Mi/0cvn cw^ Z meanjength <- s <- sd( SE <- s/sqrt( n) E <- qt( .975, df=n-l )*SE meanjength + c(-E, E)

Use the sample size from the problem

Use the mean value from the problem

Use the st. dev. from the problem

CtA ) # margin of error # This will give the lower and upper bounds of the Cl

fecal = c(213, 215, 240, 236, 217, 296, 301, 190, 197, 203, 210, 215, 270, 290, 310, 287)
meanfecal = mean(fecal)
s  = sd(fecal)
SE = s/sqrt(16)
E = qt(.975, df = 16-1)*SE
meanfecal + c(-E,E)
## [1] 220.7906 265.4594
print(meanfecal)
## [1] 243.125
print(SE)
## [1] 10.4785

7.S.5

tsum.test(1215.6, 1342.9,10,219.0,156.2,10, alternative = "greater")
## 
##  Welch Modified Two-Sample t-Test
## 
## data:  Summarized x and y
## t = 2.3311, df = 9.2435, p-value = 0.02198
## alternative hypothesis: true difference in means is greater than 0
## 95 percent confidence interval:
##  215.2416       NA
## sample estimates:
## mean of x mean of y 
##    1215.6     219.0
mechanical <-c(2966, 269,59,1,887,3452,189,93,618,130,2493)
manual <- c(186,107,65,126,123,164,408,324,548,139)


wilcox.test(mechanical,manual, alternative = "greater")
## 
##  Wilcoxon rank sum exact test
## 
## data:  mechanical and manual
## W = 69, p-value = 0.1747
## alternative hypothesis: true location shift is greater than 0

7.S.9

vermillion <-c(9,13,9,9,13,9,16,13,10,13,8,12,11)
black <- c(13,10,6,10,7,6,6,9,18)
wilcox.test(vermillion,black,alternative ="two.sided", conf.int = TRUE, conf.level = 0.90)
## Warning in wilcox.test.default(vermillion, black, alternative = "two.sided", :
## cannot compute exact p-value with ties
## Warning in wilcox.test.default(vermillion, black, alternative = "two.sided", :
## cannot compute exact confidence intervals with ties
## 
##  Wilcoxon rank sum test with continuity correction
## 
## data:  vermillion and black
## W = 80, p-value = 0.1551
## alternative hypothesis: true location shift is not equal to 0
## 90 percent confidence interval:
##  -4.993028e-05  4.000038e+00
## sample estimates:
## difference in location 
##               2.999936
vermillion <-c(9,13,9,9,13,9,16,13,10,13,8,12,11)
black <- c(13,10,6,10,7,6,6,9,18)
wilcox.test(vermillion,black,alternative ="two.sided", conf.int = TRUE, conf.level = 0.10)
## Warning in wilcox.test.default(vermillion, black, alternative = "two.sided", :
## cannot compute exact p-value with ties
## Warning in wilcox.test.default(vermillion, black, alternative = "two.sided", :
## cannot compute exact confidence intervals with ties
## 
##  Wilcoxon rank sum test with continuity correction
## 
## data:  vermillion and black
## W = 80, p-value = 0.1551
## alternative hypothesis: true location shift is not equal to 0
## 10 percent confidence interval:
##  2.999948 2.999959
## sample estimates:
## difference in location 
##               2.999936
vermillion <-c(9,13,9,9,13,9,16,13,10,13,8,12,11)
black <- c(13,10,6,10,7,6,6,9,18)
wilcox.test(vermillion,black,alternative ="greater", conf.int = TRUE)
## Warning in wilcox.test.default(vermillion, black, alternative = "greater", :
## cannot compute exact p-value with ties
## Warning in wilcox.test.default(vermillion, black, alternative = "greater", :
## cannot compute exact confidence intervals with ties
## 
##  Wilcoxon rank sum test with continuity correction
## 
## data:  vermillion and black
## W = 80, p-value = 0.07755
## alternative hypothesis: true location shift is greater than 0
## 95 percent confidence interval:
##  -6.58432e-06          Inf
## sample estimates:
## difference in location 
##               2.999936

Problem 9.S.10

expected = c(.5, .5)
observed <- c(74,61)
chisq.test(observed, p=expected)
## 
##  Chi-squared test for given probabilities
## 
## data:  observed
## X-squared = 1.2519, df = 1, p-value = 0.2632

10.S.8

died <-c(78,66)
lived <- c(76,98)
df <- data.frame(died, lived)
chisq.test(df)
## 
##  Pearson's Chi-squared test with Yates' continuity correction
## 
## data:  df
## X-squared = 3.0633, df = 1, p-value = 0.08008