The mean height of American males is 176.3 cm. The heights of the 44 male U.S. presidents (Washington through Trump) have a mean 180.1 cm and a standard deviation of 7.1 cm. Treating the 44 presidents as a simple random sample, determine if there is evidence to suggest that U.S. presidents are taller than the typical American male.
Here, we are testing the hypotheses:
\(H_0:\mu = 176.3\) cm
\(H_1:\mu > 176.3\) cm
To perform a t-test from summarized data, we need the PASWR package.
install.packages("PASWR")
Within this package, we use the tsum.test command. The syntax of the command is
tsum.test(mean.x = sample mean, s.x = sample standard deviation, n.x = sample size, mu \(\mu_0\), alternative = “greater”* or “less” or “two.sided”)
library(PASWR)
tsum.test(mean.x = 180.1,s.x = 7.1, n.x = 44, mu = 176.3, alternative = "greater")
##
## One-sample t-Test
##
## data: Summarized x
## t = 3.5502, df = 43, p-value = 0.0004736
## alternative hypothesis: true mean is greater than 176.3
## 95 percent confidence interval:
## 178.3006 Inf
## sample estimates:
## mean of x
## 180.1
The test statistic is \(t_0 = 3.550\) and the P-value is 0.0005.
The raw data for Chapter 10 of Sullivan’s Statistics: Informed Decisions Using Data 6/e can be obtained by clicking the link below:
The “fun size” of a Snickers bar is supposed to weigh 20 grams. Because the penalty for selling candy bars under their advertised weight is severe, the manufacturer calibrates the machine so the mean weight is 20.1 grams. The quality-control engineer at M&M–Mars, the Snickers manufacturer, is concerned about the calibration. He obtains a random sample of 11 candy bars, weighs them, and obtains sample data. Should the machine be shut down and calibrated?
Here, we are testing the hypotheses:
\(H_0:\mu = 20.1\) g
\(H_1:\mu \neq 20.1\) g
To perform a t-test from raw data, we use the Mosaic package.
install.packages("mosaic")
First, read the data into R. Then, use the t.test command from Mosaic. Recall, the syntax of the command is as follows:
t.test(~variable,data=data_frame_name,mu = mean in null, alternative = “greater” or “less” or “two.sided”)
Weight <- c(19.68, 20.66, 19.56, 21.5, 19.98, 20.65, 19.61, 19.74, 20.55, 20.36, 21.02)
Table1 <- data.frame(Weight) #Convert to data frame
head(Table1,n=3)
## Weight
## 1 19.68
## 2 20.66
## 3 19.56
library(mosaic)
t.test(~Weight, data=Table1,mu=20.1,alternative="two.sided")
##
## One Sample t-test
##
## data: Weight
## t = 1.0406, df = 10, p-value = 0.3226
## alternative hypothesis: true mean is not equal to 20.1
## 95 percent confidence interval:
## 19.87071 20.73111
## sample estimates:
## mean of x
## 20.30091
The test statistic is \(t_0 = 1.0406\) and the P-value is 0.3226.