Central Limit Theorem, Hypothesis Tests

Rasim Muzaffer Musal

Goals

  • Recall Central Limit Theorem.
  • Demonstrate when Central Limit Theorem applies.
  • Learn History and Motivation of Hypothesis Tests.
  • Learn basic definitions of: {alpha,p value , test statistic, t computed, t critical, 4 steps of hypothesis tests.}
  • Learn how to establish step 1 of paired sample t-test, independent samples t-test and ANOVA.
  • Run script and Interpret output.

Central Limit Theorem (C.L.T.)

  • This theorem underlies quite a bit of classical statistics.
  • Colloquially we can say that regardless of how a random variable (r.v.) is distributed, under certain conditions, the sample means from that random variable will be approximately normally distributed if the sample size is large enough.
    • Finite mean and variance.
    • Independent draws constructing the sample.

The Normal (Gaussian) and the t distribution

The normal distribution and how \(\sigma\) changes things

Recall Evaluating Density

However if we want to calculate

  • \(P(X>x)\) or \(P(X<x)\) or \(P(x_{1}<X<x_{2})\) etc…
  • We need to evaluate the area under the curve.
  • This implies we either need to integrate the f(x) we have seen earlier between the points of interest or use the standardized normal distribution.
  • The standard normal distribution is a normal distribution with mean 0 and standard deviation 1.
  • The x-axis values of the standard normal distribution are called z-scores.

Example with Normal Distribution

\[P(X<95|\mu=70,\sigma=10)\]

Recalling how prob is calculated

\[P(X<95|\mu=70,\sigma=10)\]

Using Z scores

\[P(X<95|\mu_{x}=70,\sigma_{x}=10)=P(Z<2.5|\mu_{z}=0,\sigma_{z}=1)\]

[1] 1 2

The t distribution and how \(\sigma\) changes things

Student’s t distribution

\[P(X<95|\mu=70,\sigma=10)\]

C.L.T Recalled

  • When we use C.L.T we make use of t-distribution.

  • The usage of t-distribution is standard as you have practiced. However what is going to change is to use standard error instead of standard deviation.

  • If X has a distribution with mean \(\mu_x\) and standard deviation \(\sigma_x\) averages (sample means) from that random variable will be distributed approximately normally with mean \(\mu_{x}\) and standard deviation of sample means \(\sigma_{\bar{x}}=\frac{\sigma}{\sqrt{n}}\) if n (sample size) is large enough.

Examples from C.L.T

  • We will create sample size scenarios where n={5,30,60,100}
  • Case A: Assume a random variable is Gamma distributed.
  • Case B: Assume a random variable is discrete Uniform distributed.
  • Case C: Assume a random variable is Poisson distributed.
  • Case D: Assume a mixture of Cases A+B+C.

A random variable X

  • Recall a random variable (r.v.) is a quantity of interest observed from a process that does not have predetermined outcomes. \begin{equation} X \sim Empirical\ Distribution \end{equation} \begin{equation} X \sim Named\ Distribution \end{equation}

  • Empirical Distributions are distributions of r.v. s without a set structure. They are what you observe.

  • Probability distributions are abstractions of reality that have useful attributes and structures.

Named Distributions

  • What we demonstrate in this and the next set of slides is also applicable to Empirical Distributions.

  • Assume X has a Poisson distribution. \begin{equation} X \sim Poisson(\lambda) \end{equation}

  • Greek letter \(\lambda\) is the mean and variance of X’s distribution.

Illustration of X for different \(\lambda\) values

Samples from X - Excel

  • Now imagine taking samples from each of these X populations.

  • Start out by simulating a random Poisson variable and repeat this process 5 times to create a sample size of 5.

  • Copy across 300 columns.

  • Simulating a Poisson variable in Excel via Inverse CDF:

    • Create 2 columns next to each other. First column calculates \(P(X< x | \lambda=2)\), second column has the value of x

Cumulative Distribution for X - Excel

Two columns for calculating P(X<x)

Simulating 5 r.v.s from a \(Poisson(\lambda=2)\)

We make use of the vlookup function and inverse c.d.f distribution to generate r.v.s.

p.d.f for X - R

  • Define a matrix that will have 5 rows and 300 columns
#Number of samples you are hypothetically observing
num_of_samples=300
#Sample Size
sample_size=5
#Lambda. This will later be a list for a for loop
lambda_values=2
#Create the Poisson_Object and Populate it with random Poisson variables.
Poisson_Object= matrix(nrow=sample_size,ncol=num_of_samples,data=
                         rpois(n=sample_size*num_of_samples,lambda = lambda_values))

round(table(Poisson_Object)/sum(sample_size*num_of_samples),2)
Poisson_Object
   0    1    2    3    4    5    6    7    8 
0.13 0.29 0.27 0.17 0.09 0.03 0.02 0.00 0.00 

Recalling some terms

  • \(\mu\) is population mean \(\bar{x}\) is sample mean

  • \(\sigma\) is population standard deviation \(s\) is sample standard deviation

  • \(\frac{\sigma}{\sqrt(n)}\) is standard error.

  • if you only know s, it is your best estimator for \(\sigma\).

  • if you only know \(\bar{x}\), it is your best estimator for \(\mu\).

  • degrees of freedom (d.f.) for confidence intervals is n-1.

  • the \(t_{\left((1-\frac{\alpha}{2}),df\right)} \times \frac{\sigma}{\sqrt{n}}\) is margin of error.

p.d.f for X - R

Remember the C.L.T.

  • If X has a distribution with a finite mean \((\mu)\) and standard deviation \((\sigma)\).
  • Averages from the random variable will be approximately also be normally distributed if the mean and standard deviation is finite.
  • We use this property to make inferences about averages.
  • This property is useful because you do not always have to know the shape of the orignal distribution.
  • Here we use the Poisson distribution to demonstrate its proposition.

Example of the C.L.T.

  • When X has a Poisson distribution with a known \(\lambda\).
  • We know the mean of X \((\lambda)\) and variance of X \((\lambda)\).
  • Therefore we know how \(\bar{x}\) is distributed.
  • This knowledge allows us to make inferences on \(\bar{x}\).
  • If variance of X is 2 than standard deviation is \(\sqrt{2}\).
  • Standard error is \(\frac{\sqrt{2}}{\sqrt{5}}\)
  • NOTE We only took the square root in the numerator because we knew the variance of X was 2. If you already knew the standard deviation you would not need to take the square root.

Known Parameters \(\mu\) and \(\sigma\)

  • Using C.L.T. we can calculate a confidence interval that will inform us to the locations of \(\bar{x}\). Practically the only place where I sort of see this happening is if you have historical information on a process and you assume the process is stationary.

\[\begin{equation}Upper Bound = \mu + t_{(1-\frac{\alpha}{2}),df} \times \frac{\sigma}{\sqrt{n}} \end{equation}\]

\[\begin{equation}Lower Bound = \mu - t_{(1-\frac{\alpha}{2}),df}\times \frac{\sigma}{\sqrt{n}}\end{equation}\]

Known Statistics \(\bar{x}\) and \(s\)

  • Using C.L.T. we can calculate a confidence interval that will inform us to the locations of \(\mu\).

  • The logic is that sample mean \(\bar{x}\) is your best estimator for \(\mu\) and sample standard deviation \(s\) is your best estimator for \(\sigma\)

\[\begin{equation}Upper Bound = \bar{x} + t_{(1-\frac{\alpha}{2}),df} \times \frac{s}{\sqrt{n}} \end{equation}\]

\[\begin{equation}Lower Bound = \bar{x} - t_{(1-\frac{\alpha}{2}),df}\times \frac{s}{\sqrt{n}}\end{equation}\]

Visual Example \(X \sim Poisson (\lambda=2)\)

Visualize \(\bar{x}\) from samples of \(X \sim Poisson (\lambda=2)\)

hist(colMeans(Poisson_Object),main="",xlab="")

What is the 90% CI for known pop pars.

\[\begin{align} UpperBound & =\mu + t_{\left(1-\frac{\alpha}{2},df\right)}\times \frac{\sigma}{\sqrt{n}}\\ UpperBound & =2+2.13\times \frac{\sqrt{2}}{\sqrt{5}}=3.35 \end{align}\]

\[\begin{align} LowerBound & =\mu - t_{\left(1-\frac{\alpha}{2},df\right)}\times \frac{\sigma}{\sqrt{n}}\\ LowerBound & =2-2.13\times \frac{\sqrt{2}}{\sqrt{5}}=0.65 \end{align}\]

Visualize \(\bar{x}\) from samples of \(X \sim Poisson (\lambda=2)\ with\ C.I.\)

What is the point?

  • We built this interval to give us an idea of where the sample means \((\bar{x})\) are going to be. This can let us know if a process is out of control.
  • Do not forget though that C.L.T. only applies if sample size is large enough.
  • How large will depend on the distribution of X itself. I will give you a relatively arbitrary number for this class.

Does C.L.T apply when n=5 and \(X\sim Poisson(\lambda=2)\) ?

sample_means = colMeans(Poisson_Object)
How_Many_xbar_out_of_Bounds = sum(sample_means > 3.35) + sum(sample_means < 0.65)

How_Many_xbar_out_of_Bounds/num_of_samples
[1] 0.04333333
  • We will ignore the requirement of symmetry for this example even though that is also important. For a 90% confidence interval we expect 10% of samples to be out of bounds.

Building the C.I. for sample means if you knew pop. parameters

This worksheet’s KQ column contains the formulations in the column KO

If Central Limit Theorem Holds:

  • We can claim that the sample means are going to be approximately normally distributed.

  • This allows us to construct confidence intervals around the sample (population) mean in order to make inferences about population (sample) mean(s)

If Central Limit Theorem Holds:

  • Interpretation of confidence intervals when \(\mu\) and \(\sigma\) is known is straightforward. There is a p% chance that the sample means are going to be between this lower and upper bound.

  • Inference is not so simple when you are using a sample mean and standard error to say something about where the population mean is going to be.

Example of Confidence Intervals if C.L.T. Holds

  • We will start with an example without context.
  • There is a population of X.
  • You do not know the population mean \(\mu\)
  • You do not know the population standard deviation \(\sigma\)
  • You observe sample mean \(\bar{x}=5\) and a sample standard deviation \(s=3\) within 52 observations.

Let us think about what we want to do

  • We would like to build a confidence interval say \(90\%\) to make an inference on where the population mean could possibly be.
  • Think about the excel homework you have observed in these slides.
  • Using the sample mean \(\bar{x}\) and standard error \(\frac{s}{\sqrt{n}}\) you will construct a confidence interval assuming that the central limit theorem holds.

Why do we need to think about the Central Limit Theorem

  • The averages need to have an approximate normal distribution.
  • So that you can use the t distribution (approximation of the normal distribution) and standard error \(\frac{s}{\sqrt{n}}\) to create the margin of error \(t_{((1-\frac{\alpha}{2}),df)}\frac{s}{\sqrt{n}}\) around the sample mean which is your best estimator of the population mean.

Long story shortish - Setting up the C.I.

\[UB=\bar{x}+t_{((1-\frac{\alpha}{2}),df)}\times\frac{s}{\sqrt{n}} \] \[LB=\bar{x}-t_{((1-\frac{\alpha}{2}),df)}\times\frac{s}{\sqrt{n}}\] \[UB=5+t_{((1-\frac{\alpha}{2}),df)}\times\frac{3}{\sqrt{52}} \] \[LB=5-t_{((1-\frac{\alpha}{2}),df)}\times \frac{3}{\sqrt{52}}\]

Long story shortish: Finding the t-score

  • The t-score can be found in excel using t.inv(area to left of upper bound,degrees of freedom)
  • The area to the left of upper bound for a 90% confidence interval is 0.95 (\(90\%\) + \(5\%\)). Recall that 90% is the area between upper and lower bound and 5% is the area to the left of lower bound.
  • Degrees of freedom is n-1=52-1
  • t.inv(0.95,51)=1.68
  • in the language R this can be found with qt(.95,51).

Putting it together

\[UB=5+1.68\times \frac{3}{\sqrt{52}}=5.70 \] \[LB=5-1.68\times \frac{3}{\sqrt{52}}=4.30 \]

\(90\%\) Confidence Interval

OK now build a \(99\%\) Confidence Interval

\[UB=5+t_{((1-\frac{\alpha}{2}),df)}\times \frac{3}{\sqrt{52}}= \] \[LB=5-t_{((1-\frac{\alpha}{2}),df)}\times \frac{3}{\sqrt{52}}= \]

  • t.inv(0.995,51)=2.676 in excel
  • qt(0.995,51)=2.676 in R

Why was it that we were using 0.995?

Putting it together

\[UB=5+2.675\times \frac{3}{\sqrt{52}}=6.11 \] \[LB=5-2.675\times \frac{3}{\sqrt{52}}=3.89 \]

Bottom line is:

  • Confidence Intervals built with \(\bar{x}\), \(\frac{s}{\sqrt{n}}\) and \(t_{1-\frac{\alpha}{2},df}\) allow you to make an inference on where \(\mu\) could be.

  • If you build a 90\(\%\) confidence interval(C.I.), you can say “If we built 100s of C.I. we would expect 90 out of 100 times the \(\mu\) to be inside the C.I. we build”

  • This is not a probabilistic statement since you do not assume a distribution for \(s\).

Thinking about it a bit more

  • Think back at your r or excel homework.

  • With every new sample you get a different C.I. So if you have one C.I. you really have a sample size of 1 which is what you have in a real life scenario.

  • You can not really say there is a 90\(\%\) chance \(\mu\) is going to be in a C.I. if with every sample you take you get a new C.I.

Hypothesis tests-Single Population

  • We conduct hypothesis tests to make an inference on population mean \(\mu\) based on \(\bar{x}\), \(s\), \(n\).

  • Inference will be in the form of making and the rejecting or not rejecting 2 complimentary statements on \(\mu\).

  • One of these statements will be that \(\mu\) has increased, decreased or changed compared to a constant value. \(H_{a}\)

  • The other will be the inverse. \(H_{0}\)

How do we set up the statements?

\[\begin{align} Case \quad 1:\quad & Directional \quad or \quad 1 \quad tail \quad test\\ H_{0}:\quad & \mu \le constant \\ H_{a}:\quad & \mu > constant \\ Case \quad 2:\quad & Directional \quad or \quad 1 \quad tail \quad test\\ H_{0}:\quad & \mu \ge constant \\ H_{a}:\quad & \mu < constant \\ Case \quad 3:\quad & Non-directional \quad or \quad 2 \quad tail \quad test \\ H_{0}:\quad & \mu =constant \\ H_{a}:\quad & \mu \neq constant \\ \end{align}\]

Recalling the motivation:

  • We would like to say something about \(\mu\).
  • We do not know \(\mu\) as a fact, but historical information could have been accumulated to give us an idea or it could have been assumed as an intuitive value by researchers/public etc…
  • We observe sample statistics to say something rational about whether it increased/decreased/changed.
  • We go through 4 steps in this class, textbooks differ on number of steps.

Step 1 Establish \(H_{0}\) and \(H_{a}\)

\[\begin{align} Case \quad 1:\quad & Directional \quad or \quad 1 \quad tail \quad test\\ H_{0}:\quad & \mu \le constant \\ H_{a}:\quad & \mu > constant \\ Case \quad 2:\quad & Directional \quad or \quad 1 \quad tail \quad test\\ H_{0}:\quad & \mu \ge constant \\ H_{a}:\quad & \mu < constant \\ Case \quad 3:\quad & Non-directional \quad or \quad 2 \quad tail \quad test \\ H_{0}:\quad & \mu =constant \\ H_{a}:\quad & \mu \neq constant \\ \end{align}\]

Step 2: Record the pre calculation information

  • What type of hypothesis test

    • Single Pop. directional/non directional
  • What is your \(\alpha\)

    • This is a decision variable more on it later.
  • What is your sample size

  • Identify \(t_{critical}\)

  • List \(\bar{x}\) and \(s\)

Step 3: Calculation

  • If the sample mean supports alternative hypothesis we want to calculate \(t_{computed}\) which tells us how many standard errors the sample mean is away from \(\mu\).

\[\begin{align} t_{computed} = \frac{\left(\bar{x}-\mu\right)}{\frac{s}{\sqrt{n}}} \end{align}\]

Step 4: Decision

  • If \(t_{computed}\) is further away from \(\mu\) relative to \(t_{critical}\) reject \(H_{0}\) otherwise do not.

  • If p value is smaller than \(\alpha\) reject \(H_{0}\) otherwise do not.

Conceptual question:What is \(\alpha\)

  • Probability, before you observe the data that you will reject the null hypothesis when the null hypothesis is assumed to be true at the constant value set up in step 1.

  • This is not something you actually want to do so the value is small (less than 0.1) however if we make it too small it can cause you to not reject the \(H_{0}\) when it is wrong.

  • Type 1 error is rejecting the null when the null is true.

  • Type 2 error is not rejecting the null when it is wrong.

  • \(\alpha\) is the maximum Type 1 error probability you are willing to tolerate when null hypothesis is true at the edge of (in)equality, \(\mu=constant\).

Conceptual Question: \(\alpha\) shaded

Conceptual Question: \(\alpha\) shaded

Conceptual Question: What good is \(\alpha\)?

  • At the very beginning of step 2, we do not know what \(t_{critical}\) is

  • But if we set an \(\alpha\) value . The maximum type 1 error probability you are willing to tolerate, and a sample size \(n\)

  • You can find the number of standard errors that the sample mean needs to be away from \(\mu\) before you can reject the \(H_{0}\). This number is also called \(t_{critical}\).

  • The shaded area in both plots have the same percent of area and part of the same distribution with different means and standard deviations. Allowing us to map sample mean values in terms of t scores.

Case 1:

  • An agriculture tech firm promises that the average yam yield will increase if farmers use the fertilizer they manufacture. Historically the average yam yield has been 11 tons per acre. Researchers record a random sample of yields 52 acres from various fields and find that the average yield turned out to be 12 acres on average with a standard deviation of 3. Formulate the hypothesis test to test the claim of the firm. Assume \(\alpha=0.04\)

Case 1: Step 1

\[\begin{align} H_{0}: & \mu \le 11\\ \\ H_{a}: & \mu > 11 \end{align}\]

Case 1: Step 2

  • Single population directional hypothesis test

  • \(\alpha=0.04\), \(n=52\)

  • We can find \(t_{critical}\) by using excel or R.

  • Excel: \(t.inv(1-0.04,51)=1.79\)

  • R: \(qt(1-0.04,51) = 1.79\)

  • The subtraction from 1 the \(\alpha\) value is because we want to provide to the software area to the left of \(t_{critical}\) which is to the right of \(\mu\). Hard to visualize in your mind? Draw it.

Case 1: \(t_{critical}\) Visualization

Case 1: Step 2 cont’d

  • What does this number represent? Minumum number of standard errors \(\left(\frac{s}{\sqrt{n}}\right)\) that the sample mean has to be above (since it is a positive number) the hypothesized population mean before you can reject the \(H_{0}\).

Case 1: Step 3 Calculate \(t_{computed}\)

\[\begin{align} t_{computed} = \frac{\left(\bar{x}-\mu\right)}{\frac{s}{\sqrt{n}}} \end{align}\]

\[\begin{align} t_{computed} = \frac{\left(12-11\right)}{\frac{3}{\sqrt{52}}}=2.4 \end{align}\]

  • The sample mean is 2.4 standard errors above the mean.

Case 1: Step 3 Note

  • We only calculated this because the sample mean was in the direction of the alternative hypothesis.

  • If it were not (say sample mean was 10) we would not go to Step 3 and simply conclude “We can not reject \(H_{0}\) since sample mean does not support \(H_{a}\).”

Case 1: Step 4: \(t_{computed}\) vs \(t_{critical}\)

  • Since \(t_{computed}\) is further away from the mean compared to \(t_{critical}\) we reject \(H_{0}\) and accept \(H_{a}\)

  • If you understand the statement above as is, that is great! But if you want a rule:

  • Since absolute value of \(t_{computed}\) is larger compared to \(t_{critical}\) we can reject the null hypothesis. But this only works if we have some evidence for the alternative hypothesis in the first place (sample mean does not support \(H_{0}\).

Case 1: Step 4: p value vs \(\alpha\)

  • Let us calculate the p value.

  • The alternative hypothesis have the \(>\) sign.

  • This means the p value which represents the probability of observing the sample mean you observed or larger values that are further away from the mean is to the right side of the distribution.

  • Excel and R functions we use always wants and gives you the left side of the distribution.

Case 1: Step 4: p value vs \(\alpha\) cont’d

  • In Excel \(=t.dist(t_{computed},n-1,TRUE)\)
  • In Excel \(=t.dist(2.4,51,TRUE)\)
  • In R \(pt(t_{computed},n-1)\)
  • They both return 0.99.
  • However remember this is the area to the left side of \(t_{computed}\), we want the right side since the alternative hypothesis has the \(>\) sign.
  • Therefore this needs to be subtracted from 1.
  • p = 1-0.99=0.01

Case 1: Step 4: p value vs \(\alpha\) cont’d

  • Since p value (0.01) is less than \(\alpha\) (0.04) we reject \(H_{0}\)

  • The ideas behind the other cases are identical but you just need to think about which side of the distribution is your \(t_{critical}\) and \(t_{computed}\), which side of the distribution is my \(\alpha\) and \(p\).

  • And always remember you only go to step 3 if there is any support for \(H_{a}\), what you calculate with t_{computed} is whether there is enough evidence to accept \(H_{a}\).

Case 2

Farmers are worried that the fertilizer they have been using has started to reduce their yields on average per acre. Historically the average yield of yams in per acre was 11 tons. Researchers take records of 52 random acres of yam yields and compute the sample mean to be 10 tons with a standard deviation of 3. Do the farmers have grounds to worry if alpha is 0.04? Please do a hypothesis test to help out the farmers.

Case 2: Step 1

\[\begin{align} H_{0}: & \mu \ge 11\\ \\ H_{a}: & \mu < 11 \end{align}\]

Case 2: Step 2

  • Single population directional hypothesis test

  • \(\alpha=0.04\), \(n=52\)

  • We can find \(t_{critical}\) by using excel or R.

  • Excel: \(t.inv(0.04,51)=-1.79\)

  • R: \(qt(0.04,51) = -1.79\)

  • In case 1 we did the subtraction from 1 the \(\alpha\) value is because we want to provide the area to the left of \(t_{critical}\) to the software which was to the right of \(\mu\). Hard to visualize in your mind? Draw it.

Case 2: \(t_{critical}\) Visualization

Case 2: Step 2 cont’d

  • What does this number represent? Minumum number of standard errors \(\left(\frac{s}{\sqrt{n}}\right)\) that the sample mean has to be below (since it is a negative number) the hypothesized population mean before you can reject the \(H_{0}\).

Case 1: Step 3 Calculate \(t_{computed}\)

\[\begin{align} t_{computed} = \frac{\left(\bar{x}-\mu\right)}{\frac{s}{\sqrt{n}}} \end{align}\]

\[\begin{align} t_{computed} = \frac{\left(10-11\right)}{\frac{3}{\sqrt{52}}}=-2.4 \end{align}\]

  • The sample mean is 2.4 standard errors below the mean.

Case 2: Step 3 Note

  • We only calculated this because the sample mean was in the direction of the alternative hypothesis.

  • If it were not (say sample mean was 12) we would not go to Step 3 and simply conclude “We can not reject \(H_{0}\) since sample mean does not support \(H_{a}\).”

Case 2: Step 4: \(t_{computed}\) vs \(t_{critical}\)

  • Since \(t_{computed}\) is further away from the mean compared to \(t_{critical}\) we reject \(H_{0}\) and accept \(H_{a}\)

  • If you understand the statement above as is, that is great! But if you want a rule:

  • Since absolute value of \(t_{computed}\) is larger compared to \(t_{critical}\) we can reject the null hypothesis. But this only works if we have some evidence for the alternative hypothesis in the first place (sample mean does not support \(H_{0}\)).

Case 2: Step 4: p value vs \(\alpha\)

  • Let us calculate the p value.

  • The alternative hypothesis have the \(<\) sign.

  • This means the p value which represents the probability of observing the sample mean you observed or larger values that are further away from the mean is to the left side of the distribution.

  • Excel and R functions we use always wants and gives you the left side of the distribution.

Case 2: Step 4: p value vs \(\alpha\) cont’d

  • In Excel \(=t.dist(t_{computed},n-1,TRUE)\)
  • In Excel \(=t.dist(-2.4,51,TRUE)\)
  • In R \(pt(t_{computed},n-1)\)
  • They both return 0.01.
  • Remember this is the area to the left side of \(t_{computed}\), we do NOT want the right side since the alternative hypothesis has the \(<\) sign.
  • Therefore this does NOT need to be subtracted from 1.
  • p =0.01

Case 2: Step 4: p value vs \(\alpha\) cont’d

  • Since p value (0.01) is less than \(\alpha\) (0.04) we reject \(H_{0}\)

  • The ideas behind the other cases are identical but you just need to think about which side of the distribution is your \(t_{critical}\) and \(t_{computed}\), which side of the distribution is my \(\alpha\) and \(p\).

  • And always remember you only go to step 3 if there is any support for \(H_{a}\), what you calculate with t_{computed} is whether there is enough evidence to accept \(H_{a}\).

Case 3:

Farmers are worried that the fertilizer they have been using has started to change their yields on average per acre. Historically the average yield of yams in per acre was 11 tons. Researchers take records of 52 random acres of yam yields and compute the sample mean to be 10 tons with a standard deviation of 3. Do the farmers have grounds to worry if alpha is 0.04? Please do a hypothesis test to help out the farmers.

Case 3: Step 1

\[\begin{align} H_{0}: & \mu = 11\\ \\ H_{a}: & \mu \neq 11 \end{align}\]

Case 3: Step 2

  • Single population non-directional hypothesis test

  • \(\alpha=0.04\), \(n=52\)

  • We can find \(t_{critical}\) by using excel or R.

  • The difference here is that we need to divide \(\alpha\) by 2 \(\frac{\alpha}{2}=0.02\). We are looking for evidence against the null hypothesis on both sides of the distribution. You will have 2 sets of \(t_{critical}\)

  • Excel: \(t.inv(0.02,51)=-2.1\)

  • R: \(qt(0.02,51) = -2.1\)

  • Excel: \(t.inv(1-0.02,51)=2.1\)

  • R: \(qt(1-0.02,51) = 2.1\)

  • Since the t-distribution is symmetric just like the normal distribution you only need to use the software once to get the first \(t_{critical}\) which will have the opposite sign for the second \(t_{critical}\).

Case 3: \(t_{critical}\) Visualization

Case 3: Step 2 cont’d

  • What do these numbers represent? Minumum number of standard errors \(\left(\frac{s}{\sqrt{n}}\right)\) that the sample mean has to be away (it can be in both sides of the distribution) from the hypothesized population mean before you can reject the \(H_{0}\). This sounds very much like the other cases but in this case you look for evidence against the null hypothesis on both sides of the mean.

Case 3: Step 3 Calculate \(t_{computed}\)

\[\begin{align} t_{computed} = \frac{\left(\bar{x}-\mu\right)}{\frac{s}{\sqrt{n}}} \end{align}\]

\[\begin{align} t_{computed} = \frac{\left(10-11\right)}{\frac{3}{\sqrt{52}}}=-2.4 \end{align}\]

  • The sample mean is 2.4 standard errors below the mean.

Case 3: Step 3 Note

  • For case 3, we would reach the exact same conclusion if we observed the sample mean to be 12.

Case 3: Step 4: \(t_{computed}\) vs \(t_{critical}\)

  • Since \(t_{computed}\) is further away from the mean compared to \(t_{critical}\) we reject \(H_{0}\) and accept \(H_{a}\)

  • If you understand the statement above as is, that is great! But if you want a rule:

  • Since absolute value of \(t_{computed}\) is larger compared to \(t_{critical}\) we can reject the null hypothesis.

  • For case 3 we would reach the same conclusion if the sample mean was observed to be 12 leading to \(t_{computed}\) of 2.4.

Case 3: Step 4: p value vs \(\alpha\)

  • Let us calculate the p value.

  • The alternative hypothesis have the \(\neq\) sign.

  • This means the p value which represents the probability of observing the sample mean you observed or larger values that are further away from the mean is both sides of the distribution.

  • Excel and R functions we use always wants and gives you the left side of the distribution.

Case 3: Step 4: p value vs \(\alpha\) cont’d

  • In Excel \(=t.dist(t_{computed},n-1,TRUE)\)
  • In Excel \(=t.dist(-2.4,51,TRUE)\)
  • In R \(pt(t_{computed},n-1)\)
  • They both return 0.01.
  • Remember this is the area to the left side of \(t_{computed}\), and represents half of p.
  • Therefore this needs to be multiplied with 2.
  • \(p =\frac{p}{2}= 0.01\times2 = 0.02\)

Case 3: Step 4: p value vs \(\alpha\) cont’d

  • Since p value (0.02) is less than \(\alpha\) (0.04) we reject \(H_{0}\).

  • The ideas behind the other cases are identical but you need to remember in case 3 we work with both sides of the t-distribution. This leads to awkward calculations involving \(\alpha\) and p-value.