Problems based on those from Hogg, Tanis, and Zimmerman textbook but slightly reworded.
Assume the weight of cereal in a “12.6 ounce box” is normal with known standard deviation 0.2. The Food and Drug Administration allows only a small percentage of boxes to contain less than 12.6 ounces. 25 boxes are sampled, producing a sample mean of 12.9 ounces. Based on this sample, test whether the mean weight of all “12.6 ounce” boxes is less than 13 ounces.
Let X equal the Brinell hardness measurement of ductile iron subcritically annealed. Assume that the distribution of X is normal with known variance 100. Test whether the mean is greater than 170 by using the following data: 170, 167, 174, 179, 156, 179, 163, 156, 187, 156, 183, 179, 174, 179, 170, 156, 187, 179, 183, 174, 187, 167, 159, 170, 179.
Let X denote the thickness of spearmint gum manufactured for vending machines. The target thickness is 7.5 hundredths of an inch. Assume that the distribution of X is normal with known standard deviation 0.3 hundredths of an inch. Test whether the mean thickness is 7.5 hundredths of an inch using the following data: 7.65, 7.60, 7.65, 7.70, 7.55, 7.55, 7.40, 7.40, 7.50, 7.50.
Let X equal the thickness of spearmint gum manufactured for vending machines. Assume the distribution of X is normal with unknown mean and unknown variance. The target thickness is 7.5 hundredths of an inch. Test whether the mean thickness is 7.5 hundredths of an inch using the data at http://cknudson.com/data/gumthickness.csv. Gumdata <- read.csv(http://cknudson.com/data/gumthickness.csv)
Let X equal the forced vital capacity (FVC) in liters for a female college student. (The FVC is the amount of air that a student can force out of her lungs.) Assume that the distribution of X is approximately normal with unknown mean and variance. Suppose it is known that the mean is 3.4 liters. A volleyball coach claims that the FVC of volleyball players is greater than 3.4 liters. Test the coach’s claim with the data at http://cknudson.com/data/FVC.csv
Among the data collected for the World Health Organization air quality monitoring project is a measure of suspended particulars in micrograms per cubic meters. Let X and Y equal the concentration of suspended particles (in micrograms per cubic meters) in the city centers (commercial districts) of Melbourne and Houston, respectively. Using n = 13 observations of X and m = 16 observations of Y, test whether the mean concentration of suspended particles is lower in Melbourne than in Houston. The mean and standard deviation for Melbourne are 72.9 and 25.6, respectively. The mean and standard deviation for Houston are 81.7 and 28.3, respectively. Use a significance level of .1.
Some nurses in county public health conducted a survey of women who had received in adequate prenatal care. They used information from birth certificates to select mothers for the survey. The selected mothers were divided into two groups: 14 mothers who said they had five or fewer prenatal visits and 14 mothers who said they had six or more prenatal visits. Let X and Y equal the respective birth weights of babies from these two sets of mothers, and assume that the distribution of X is N(μ_x,σ^2) and the distribution of Y is N(μ_Y,σ^2). The observations of X were 49, 108, 110, 82, 93, 114, 134, 114, 96, 52, 101, 114, 120, 116. The observations of Y were 133, 108, 93, 119, 119, 98, 106, 131, 87, 153, 116, 129, 97, 110. Test whether mothers with 5 or fewer prenatal visits have lower birth weight babies than mothers with 6 of more prenatal visits. Rather than re-typing the data, you can use the csv at http://cknudson.com/data/birthweights.csv For more practice, try 8.2.10 and 8.2.14 (optional).
If a newborn baby has a birthweight that is less than 2500 grams (5.5 pounds), we say that the baby has a low birth weight. The proportion of babies with a low birth weight is an indicator of lack of nutrition for the mothers. For the US, approximately 7% of babies have a low birth weight. Let p equal the proportion of babies born in Sudan who weight less than 2500 grams. Test whether p is less than 7%. In a random sample of 209 babies, 23 weighted less than 2500 grams. Use a significance level of .05.
Let p equal the proportion of drivers who use a seatbelt in a state that does not have a mandatory seat belt law. It was claimed that p = .14. An advertising campaign was conducted to increase this proportion. Two months after the campaign, 104 drivers out of a random sample of 590 drivers were wearing their seat belts. Was the campaign successful?
A machine shop that manufactures toggle levers has both a day and a night shift. A toggle lever is defective if a standard nut cannot be screwed onto the threads. A random sample of size 1000 was taken from the day shift and (independently) a random sample of size 1000 was taken from the night shift. The day shift had 37 defectives and the night shift had 53 defectives. Test whether there is a difference in the proportion of defective toggle levers produced by the day shift and the night shift.
Use the definition of low birth weight from problem 5. Of 900 babies born in Africa, 135 had low birth weight. Of 700 babies born in the Americas, 77 had low birth weight. Test whether the proportion of American babies born with low birth weight is smaller than the proportion of African babies of low birth weight.
To test whether a golf ball of brand A can be hit a greater distance off the tee than a golf ball of brand B, each of 17 golfers hit a ball of each brand, 8 hitting ball A before ball B and 9 hitting ball B before ball A.
Golfdata <- read.csv("http://cknudson.com/data/golfballs.csv")
Test whether prisoners’ stress level changed between entering and leaving prison.
library(PairedData)
## Loading required package: MASS
## Loading required package: gld
## Loading required package: mvtnorm
## Loading required package: lattice
## Loading required package: ggplot2
##
## Attaching package: 'PairedData'
## The following object is masked from 'package:base':
##
## summary
data(PrisonStress)
Some of the participants in the prison study were physically trained during their time in prison. The thinking is that physical exercise helps with stress reduction. Determine whether the change in stress levels differed between thsoe who were physically trained and those who were not.
Our hypotheses are:
Let’s use a significance level of α = 0.05.
cerealSD <- 0.2
cerealMean <- 12.9
cerealDim <- 25
cerealTestStat <- (cerealMean - 13)/(cerealSD / sqrt(cerealDim))
(pval <- pnorm(cerealTestStat, lower.tail = TRUE))
## [1] 0.006209665
We reject the null hypothesis because the pvalue 0.0062097 is smaller than alpha. The mean weight of so-called 12.6oz cereal boxes is significantly smaller than 13oz.
Quick check: it makes sense that our p-value is very small (rather than very large) because our sample mean is smaller than 13, and our alternative hypothesis involves <.
Our hypotheses are:
Let’s use a significance level of α = 0.05.
munaught <- 170
hardnessData <- c(170, 167, 174, 179, 156, 179, 163, 156, 187, 156, 183, 179, 174, 179, 170, 156, 187, 179, 183, 174, 187, 167, 159, 170, 179)
(hardnessMean <- mean(hardnessData))
## [1] 172.52
hardnessVar <- 100
(hardnessTestStat <- (hardnessMean - munaught)/sqrt(hardnessVar/length(hardnessData)))
## [1] 1.26
(pval <- pnorm(hardnessTestStat, lower.tail = FALSE))
## [1] 0.1038347
We fail to reject the null hypothesis because the pvalue 0.1038347 is greater than alpha. The mean Brinnell hardness is not greater than 170.
Let’s use a significance level of α = 0.05.
munaught <- 7.5
thiccData <- c(7.65, 7.6, 7.65, 7.7, 7.55, 7.55, 7.4, 7.4, 7.5, 7.5)
(thiccMean <- mean(thiccData))
## [1] 7.55
thiccSD <- 0.3
(thiccTestStat <- (thiccMean - munaught)/(thiccSD/sqrt(length(thiccData))))
## [1] 0.5270463
(pval <- 2*pnorm(thiccTestStat, lower.tail = F))
## [1] 0.5981615
We fail to reject the null hypothesis because the pvalue 0.5981615 is larger than alpha. The mean gum thickness is not different from 7.5 hundredths of an inch.
gumData <- read.csv(url("http://www.cknudson.com/data/gumthickness.csv"))
gumData <- gumData$x
#gumData <- c(7.65, 7.6, 7.65, 7.7, 7.55, 7.55, 7.4, 7.4, 7.5, 7.5)
Let’s use a significance level of α = 0.05.
muNaught <- 7.5
(gumMean <- mean(gumData))
## [1] 7.55
(gumVar <- var(gumData))
## [1] 0.01055556
(gumDim <- length(gumData))
## [1] 10
(gumTestStat <- (gumMean - muNaught)/sqrt(gumVar/gumDim))
## [1] 1.538968
(pval <- 2*pt(gumTestStat, df = gumDim - 1, lower.tail = F))
## [1] 0.1581954
We fail to reject the null hypothesis because the pvalue, 0.1581954, is larger than alpha. The mean gum thickness is not different from 7.5 hundredths of an inch.
Let’s use a significance level of α = 0.05.
fvcData <- read.csv("http://cknudson.com/data/FVC.csv")
fvcData <- fvcData$x
muNaught <- 3.4
(fvcMean <- mean(fvcData))
## [1] 3.555556
(fvcVar <- var(fvcData))
## [1] 0.02777778
(fvcDim <- length(fvcData))
## [1] 9
(fvcTestStat <- (fvcMean - muNaught)/sqrt(fvcVar/fvcDim))
## [1] 2.8
(pval <- pt(fvcTestStat, df = fvcDim - 1, lower.tail = FALSE))
## [1] 0.01159892
We reject the null hypothesis because 0.0115989 is less than alpha. The FVC of volleyball players is significantly greater than 3.4 L.
Let’s use a significance level of α = 0.05.
xn <- 13
yn <- 16
xMean <- 72.9
xSD <- 25.6
yMean <- 81.7
ySD <- 28.3
(airSPooled <- sqrt(((xn - 1)*xSD^2 + (yn - 1)*ySD^2)/(xn+yn - 2)))
## [1] 27.13319
(airTestStat <- (xMean - yMean) / (airSPooled*sqrt((1/xn) + (1/yn))))
## [1] -0.8685893
(pval <- pt(airTestStat, df = xn + yn - 2))
## [1] 0.1963637
We fail to reject the null hypothesis because the pvalue, 0.1963637, is greater than alpha. The concentration of suspended particulars in Melbourne is not significantly higher than in Houston.
Let’s use a significance level of α = 0.1.
birthData <- read.csv("http://cknudson.com/data/birthweights.csv")
birthDataX <- character()
birthDataY <- character()
n <- length(birthData$birthweight)
for (i in 1:n) {
if (1 == birthData$fiveorfewer[i]) {
birthDataX <- c(birthDataX, birthData$birthweight[i])
} else {
birthDataY <- c(birthDataY, birthData$birthweight[i])
}
}
birthDataX <- as.numeric(birthDataX)
birthDataY <- as.numeric(birthDataY)
#Sometimes it's easier to just retype the numbers.
(xL <- length(birthDataX))
## [1] 14
(yL <- length(birthDataY))
## [1] 14
(xMean <- mean(birthDataX))
## [1] 100.2143
(yMean <- mean(birthDataY))
## [1] 114.2143
(xVar <- var(birthDataX))
## [1] 604.489
(yVar <- var(birthDataY))
## [1] 329.2582
(spool <- sqrt(((xL - 1)*xVar + (yL - 1)*yVar) / (xL + yL - 2)))
## [1] 21.60726
(birthTestStat <- (xMean - yMean) / (spool*sqrt((1/xL) + (1/yL))))
## [1] -1.714263
(pval <- pt(birthTestStat, df = xL + yL - 2))
## [1] 0.04918966
We can reject the null hypothesis because the pvalue, 0.0491897, is less than alpha. Mothers with 5 or fewer prenatal visits birth babies with significantly lower birth weights than those of babies birthed by mothers with 6 or more prenatal visits.
Let’s use a significance level of α = 0.05.
pnaught <- 0.07
totalBabies <- 209
skinnyBabies <- 23
(skinnyProp <- skinnyBabies/totalBabies)
## [1] 0.1100478
(babySD <- sqrt(pnaught * (1 - pnaught) / totalBabies))
## [1] 0.01764889
(babyTestStat <- (skinnyProp - pnaught) / babySD)
## [1] 2.269143
(pval <- pnorm(babyTestStat))
## [1] 0.9883702
We fail to reject the null hypothesis because our pvalue, 0.9883702, is greater than alpha. Sudan does not have significantly fewer babies who weigh less than 2.5 kg than 7%.
Let’s use a significance level of α = 0.05.
pnaught <- 0.14
totalDrivers <- 590
beltedDrivers <-104
(beltProp <- beltedDrivers/totalDrivers)
## [1] 0.1762712
(beltSD <- sqrt(pnaught*(1 - pnaught) / totalDrivers))
## [1] 0.01428523
(driverTestStat <- (beltProp - pnaught) / beltSD)
## [1] 2.539069
(pval <- pnorm(driverTestStat, lower.tail = F))
## [1] 0.005557393
We can reject the null hypothesis because the pvalue, 0.0055574, is less than alpha. So the campaign was successful. The proportion of belted drivers rose significantly.
Let’s use a significance level of α = 0.05.
xL <- yL <- 1000
xDefectCt <- 37
yDefectCt <- 53
(pxDefect <- xDefectCt/xL)
## [1] 0.037
(pyDefect <- yDefectCt/yL)
## [1] 0.053
(pHatDefect <- (xDefectCt + yDefectCt) / (xL + yL))
## [1] 0.045
(defectTestStat <- abs(pxDefect - pyDefect) / sqrt(pHatDefect * (1 - pHatDefect) *(1/xL + 1/yL)))
## [1] 1.725826
(pval <- 2*pnorm(defectTestStat, lower.tail = F))
## [1] 0.0843787
We fail to reject the null hypothesis because our pvalue, 0.0843787, is greater than alpha. There was no significant difference in the proportion of defects produced during the day shift and the night shift.
Let’s use a significance level of α = 0.05.
xL <- 900
yL <- 700
skinnyBabiesX <- 135
skinnyBabiesY <- 77
(pSkinnyX <- skinnyBabiesX/xL)
## [1] 0.15
(pSkinnyY <- skinnyBabiesY/yL)
## [1] 0.11
(pHatSkinny <- (skinnyBabiesX + skinnyBabiesY) / (xL + yL))
## [1] 0.1325
(skinnyBabyTestStat <- (pSkinnyX - pSkinnyY) / sqrt(pHatSkinny * (1 - pHatSkinny) * (1/xL + 1/yL)))
## [1] 2.341141
(pval <- pnorm(skinnyBabyTestStat, lower.tail = F))
## [1] 0.009612449
We reject the null hypothesis because our pvalue, 0.0096124, is less than alpha. The proportion of babies with low birth rate in America was significantly lower than the proportion in Africa.
b ~ Brand B a ~ Brand A - Ho: μa = μb - Ha: μa - μb > 0
Let’s use a significance level of α = 0.05.
golfballData <- read.csv("http://cknudson.com/data/golfballs.csv")
ABdiff <- c(golfballData$BallA - golfballData$BallB)
(golfMean <- mean(ABdiff))
## [1] 4.764706
(golfLength <- length(ABdiff))
## [1] 17
(golfSD <- sd(ABdiff))
## [1] 9.086593
(golfTestStat <- golfMean / (golfSD / sqrt(golfLength)))
## [1] 2.162019
(pval <- pt(golfTestStat, df = golfLength - 1, lower.tail = F))
## [1] 0.02305597
We can reject the null hypothesis because our pvalue, 0.023056, is less than alpha. The average distance brand A balls travel is significantly more than that of brand B balls.
Y/n ~ N(p, sqrt(p*q/n)) p = (Y1 + Y2)/(n1 + n2)
x ~ Before y ~ After - Ho: px = py - Ha: px - py ≠ 0
Let’s use a significance level of α = 0.05.
library(PairedData)
data(PrisonStress)
stressDiff <- c(PrisonStress$PSSbefore - PrisonStress$PSSafter)
(stressMean <- mean(stressDiff))
## [1] -0.8461538
(stressLength <- length(stressDiff))
## [1] 26
(stressSD <- sd(stressDiff))
## [1] 9.194313
(stressTestStat <- stressMean / (stressSD / sqrt(stressLength)))
## [1] -0.4692635
(pval <- 2* pt(abs(stressTestStat), df = stressLength - 1, lower.tail = F))
## [1] 0.6429482
We fail to reject the null hypothesis because our pvalue, 0.6429482, is greater than alpha. There is not a significant difference in stress before and after a prison sentence.
x ~ Before y ~ After - Ho: py = px - Ha: py - px < 0
Let’s use a significance level of α = 0.05.
sportyGroup <- subset(PrisonStress, Group == "Sport")
stressDiff <- c(sportyGroup$PSSafter - sportyGroup$PSSbefore)
(stressMean <- mean(stressDiff))
## [1] -3.933333
(stressLength <- length(stressDiff))
## [1] 15
(stressSD <- sd(stressDiff))
## [1] 5.675343
(stressTestStat <- stressMean / (stressSD / sqrt(stressLength)))
## [1] -2.684196
(pval <- pt(abs(stressTestStat), df = stressLength - 1, lower.tail = F))
## [1] 0.008899414
We can reject the null hypothesis because the pvalue, 0.0088994, is less than alpha. The mean stress level after athletic training was significantly lower than before.