### Chapter 7. Hypothesis Testing: One-sample t-test

### One-sample t-test: Test Statistic and p-value

One-sample t-test: Test Statistic

The test statistic of a *one-sample #t#-test* for a population mean #\mu# is denoted #t#.

The calculation of the #t#-statistic is nearly identical to the calculation of the #Z#-statistic. The only difference being:

- The #Z#-statistic is calculated using the (true) #\blue{\text{standard error of the mean}\,\sigma_{\bar{X}}}#.

\[Z = \cfrac{\bar{X}-\mu_0}{\blue{\sigma_{\bar{X}}}} = \cfrac{\bar{X}-\mu_0}{\blue{\sigma/\sqrt{n}}}\phantom{00000000000000}\] - The #t#-statistic is calculated using the #\orange{\text{estimated standard error of the mean}\,s_{\bar{X}}}#.

\[t = \cfrac{\bar{X}-\mu_0}{\orange{s_{\bar{X}}}} = \cfrac{\bar{X}-\mu_0}{\orange{s/\sqrt{n}}}\phantom{00000000000000}\]

Under the null hypothesis of a *one-sample #t#-test*, the #t#-statistic follows a #t#*-distribution* with #df = n - 1# degrees of freedom.

\[t \sim t_{n-1}\]

Student's t-Distribution

The shape of a #\boldsymbol{t}#**-distribution** is very similar to that of the *Standard Normal Distribution*, except that it has *thicker *tails and a *lower *peak. The exact shape is dependent on the number of degrees of freedom.

As the number of degrees of freedom increases, the difference between the *sample standard deviation* #s# and the *population standard deviation* #\sigma# decreases and the #t#-distribution will tend towards the *Standard Normal Distribution*.

Calculating the p-value of a one-sample t-test for a Population Mean with Statistical Software

The calculation of the #p#-value of a #t#-test for #\mu# is dependent on the *direction *of the test and can be performed using either Excel or R.

To calculate the #p#-value of a #t#-test for #\mu# in **Excel**, make use of one of the following commands:

\[\begin{array}{llll}

\phantom{0}\text{Direction}&\phantom{0000}H_0&\phantom{0000}H_a&\phantom{000000000}\text{Excel Command}\\

\hline

\text{Two-tailed}&H_0:\mu = \mu_0&H_a:\mu \neq \mu_0&=2 \text{ * }(1 \text{ - } \text{T.DIST}(\text{ABS}(t),n\text{ - }1,1))\\

\text{Left-tailed}&H_0:\mu \geq \mu_0&H_a:\mu \lt \mu_0&=\text{T.DIST}(t,n\text{ - }1,1)\\

\text{Right-tailed}&H_0:\mu \leq \mu_0&H_a:\mu \gt \mu_0&=1\text{ - }\text{T.DIST}(t,n\text{ - }1,1)\\

\end{array}\]

To calculate the #p#-value of a #t#-test for #\mu# in **R**, make use of one of the following commands:

\[\begin{array}{llll}

\phantom{0}\text{Direction}&\phantom{0000}H_0&\phantom{0000}H_a&\phantom{00000000000}\text{R Command}\\

\hline

\text{Two-tailed}&H_0:\mu = \mu_0&H_a:\mu \neq \mu_0&2 \text{ * }\text{pt}(\text{abs}(t),n\text{ - }1,lower.tail=\text{FALSE})\\

\text{Left-tailed}&H_0:\mu \geq \mu_0&H_a:\mu \lt \mu_0&\text{pt}(t,n\text{ - }1, lower.tail=\text{TRUE})\\

\text{Right-tailed}&H_0:\mu \leq \mu_0&H_a:\mu \gt \mu_0&\text{pt}(t,n\text{ - }1, lower.tail=\text{FALSE})\\

\end{array}\]

If #p \leq \alpha#, reject #H_0# and conclude #H_a#. Otherwise, do not reject #H_0#.

The engineer collects a random sample of #47# new batteries and measures the performance of each one.

She plans on using a

*one-sample #t#-test*to determine if the mean range of the new battery significantly

*differs*from #475# km, at the #\alpha = 0.01# level of significance.

The sample mean #\bar{X}# turns out to be #470.0# km with a standard deviation of #s=12.1# km.

Calculate the #p#-value of the test and make a decision regarding #H_0#. Round your answer to #4# decimal places.

On the basis of this #p#-value, #H_0# should be rejected, because #\,p# #\lt# #\alpha#.

There are a number of different ways we can calculate the #p#-value of the test. Click on one of the panels to toggle a specific solution.

A sample size of #n=47# is considered large enough for the *Central Limit Theorem *to apply.

This means that, although the sample in question comes from a population having an unknown distribution, the test statistic

\[t=\cfrac{\bar{X} - \mu_0}{s/\sqrt{n}}\]

approximately has the #t_{n-1} = t_{46}# distribution, under the assumption that #H_0# is true.

Calculate the value of *test statistic *#t#:

\[t = \cfrac{\bar{X}-\mu_0}{s/\sqrt{n}} =\cfrac{470.0 - 475}{12.1/\sqrt{47}} = -2.83292\]

To calculate the #p#-value of a* *#t#-test, make use of the following Excel function:

T.DIST(x, deg_freedom, cumulative)

x: The value at which you wish to evaluate the distribution function.deg_freedom: An integer indicating the number of degrees of freedom.cumulative: A logical value that determines the form of the function.

- TRUE - uses the cumulative distribution function, #\mathbb{P}(X \leq x)#
- FALSE - uses the probability density function

Since we are dealing with a *two-tailed *#t#-test, run the following command to calculate the #p#-value:

\[

=2 \text{ * }(1 \text{ - } \text{T.DIST}(\text{ABS}(t),n \text{ - } 1,1))\\

\downarrow\\

=2 \text{ * }(1 \text{ - } \text{T.DIST}(\text{ABS}(\text{-}2.83292), 47 \text{ - } 1,1))

\]

This gives:

\[p = 0.0068\]

Since #\,p# #\lt# #\alpha#, #H_0: \mu = 475# should be rejected.

A sample size of #n=47# is considered large enough for the *Central Limit Theorem *to apply.

This means that, although the sample in question comes from a population having an unknown distribution, the test statistic

\[t=\cfrac{\bar{X} - \mu_0}{s/\sqrt{n}}\]

approximately has the #t_{n-1} = t_{46}# distribution, under the assumption that #H_0# is true.

Calculate the value of *test statistic *#t#:

\[t = \cfrac{\bar{X}-\mu_0}{s/\sqrt{n}} =\cfrac{470.0 - 475}{12.1/\sqrt{47}} = -2.83292\]

To calculate the #p#-value of a* *#t#-test, make use of the following R function:

pt(q, df, lower.tail)

q: The value at which you wish to evaluate the distribution function.df: An integer indicating the number of degrees of freedom.lower.tail: If TRUE (default), probabilities are #\mathbb{P}(X \leq x)#, otherwise, #\mathbb{P}(X \gt x)#.

Since we are dealing with a *two-tailed *#t#-test, run the following command to calculate the #p#-value:

\[

2 \text{ * } \text{pt}(q = \text{abs}(t), df = n \text{ - } 1, lower.tail = \text{FALSE})\\

\downarrow\\

2\text{ * } \text{pt}(q = \text{abs}(\text{-}2.83292), df = 47 \text{ - } 1,lower.tail = \text{FALSE})

\]

This gives:

\[p = 0.0068\]

Since #\,p# #\lt# #\alpha#, #H_0: \mu = 475# should be rejected.

**Pass Your Math**independent of your university. See pricing and more.

Or visit omptest.org if jou are taking an OMPT exam.