Section 7.1: One-Sample t Procedures

Example 1: Watching Videos on a Mobile Phone

Below are the commands that correspond to the problems from the in-class handout.

Question 1

Load the data into R Stuido:

video<-read.file("/home/emesekennedy/Data/Ch7/videophone.txt")
## Reading data with read.table()

Part a)

Find the sample mean \(\bar{x}\) and the sample standrad deviation \(s\)

mean(~Hours, data=video)
## [1] 6.75
sd(~Hours, data=video)
## [1] 3.882194

Part b)

Find the standard error for \(\bar{x}\) (\(SE_{\bar{x}}=\frac{s}{\sqrt{n}}\)):

3.88/sqrt(8)
## [1] 1.371787

Part c)

Find \(t^*\) for the 95% confidence interval for \(\mu\) by either using the command xqt or qdist:

xqt(.025, df=7)

## [1] -2.364624
xqt(.975, df=7)

## [1] 2.364624
qdist("t",df=7, c(.025, .975))

## [1] -2.364624  2.364624

So \(t^*=2.365\).

Part d)

Find the margin of error (\(m=t^*\frac{s}{\sqrt{n}}\)):

2.364*1.37
## [1] 3.23868

Part e)

Find the 95% confidence interval for \(\mu\) (\(\bar{x}\pm m\)):

6.75+3.24
## [1] 9.99
6.75-3.24
## [1] 3.51

So the 95% confidence interval for \(\mu\) is \((3.51, 9.99)\)

Question 2

Part a)

The null hypothesis is \(H_0: \mu=3.7\) and the alternative hypothesis is \(H_a: \mu\ne3.7\)

Part b)

Find the value of the t statistic \(\left(\displaystyle t=\frac{\bar{x}-\mu_0}{\frac{s}{\sqrt{n}}}\right)\):

(6.75-3.7)/1.37
## [1] 2.226277

So \(t=2.226\).

Part c)

Find the P-value:

2*xpt(-2.226, df=7)

## [1] 0.0613318

So the P-value is .0613.

Part d)

The P-value is greater than .05, so we cannot reject the null hypothesis at the 5% significance level. This means that the data does not provide sufficient evidence to conclude that the U.S. college student average is different from the reported overall U.S. average a the 5% significance level.

Question 3

To test whether the U.S. college student average is larger than the overall U.S. population average, we can use the one-sided alternative hypothesis \(H_a: \mu>3.7\). The new alternative does not change value of the \(t\) statistic, but it effects the P-value.

xpt(-2.226, df=7)

## [1] 0.0306659

The P-value for this test is .03067, which is less than .05. This means that we can reject the null hypothesis at the 5% significance level, so there is enough evidence to conclude that the U.S. college student average is larger than the overall U.S. population average.

We can use the following commands to confirm our results.

t.test(~Hours, data=video, mu=3.7)
## 
##  One Sample t-test
## 
## data:  data$Hours
## t = 2.2221, df = 7, p-value = 0.06168
## alternative hypothesis: true mean is not equal to 3.7
## 95 percent confidence interval:
##  3.504405 9.995595
## sample estimates:
## mean of x 
##      6.75

To use a one sided alternative that the mean is greater than the hypothesized value, include the optional argument alternative=“greater”

t.test(~Hours, data=video, mu=3.7, alternative="greater")
## 
##  One Sample t-test
## 
## data:  data$Hours
## t = 2.2221, df = 7, p-value = 0.03084
## alternative hypothesis: true mean is greater than 3.7
## 95 percent confidence interval:
##  4.149572      Inf
## sample estimates:
## mean of x 
##      6.75

By default, t.test gives the 95% confidence interval. We can change this to 99% confidence interval (you can use any other confidence level as well) by using the optional command conf.level=.99

t.test(~Hours, data=video, mu=3.7, conf.level=.99)
## 
##  One Sample t-test
## 
## data:  data$Hours
## t = 2.2221, df = 7, p-value = 0.06168
## alternative hypothesis: true mean is not equal to 3.7
## 99 percent confidence interval:
##   1.946739 11.553261
## sample estimates:
## mean of x 
##      6.75