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) distribution

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

Recall Evaluating Density

Calculating probabilities in continous distributions

  • \(P(X>x_{1})\) or \(P(X<x_{2})\) 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 vs Normal Distributions

Student’s t distribution

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

Student’s t-distribution

  • Probability that t is going to be less than 2.5 both in R and Excel for different degrees of freedoms.

\[\begin{aligned} P(t<2.5 \vert \nu=4)=& R: pt(2.5,4)=0.97, \\ Excel: =&T.DIST(2.5,4,TRUE)\\ P(t<2.5 \vert \nu=29)=& R: pt(2.5,29)=0.99, \\ Excel: =&T.DIST(2.5,29,TRUE)\\ \end{aligned} \]

C.L.T Recalled

  • C.L.T. is used to make inferences about averages.

  • The usage of t-distribution is similar to z-scores. It is important that we use standard error instead of standard deviation when we make inferences for means.

  • 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.

t vs z, s and \(\sigma\) vs \(\sigma\) and \(\sigma\)

  • For making probabilistic statements about X=x we use standard deviation.
  • For making probabilistic statements about \(\mu\) or \(\bar{x}\) we use standard error.
  • If we know population \(\sigma\) and \(\mu\) use z-scores to make inferences about \(\bar{x}\) otherwise use \(t\) scores.

t vs z, s and \(\sigma\) vs \(s_{X}\) and \(\sigma_{X}\)

\[\begin{aligned} &z_{x}=&\frac{(x-\mu)}{\sigma_{x}} \\ &t_{x}=&\frac{(x-\bar{x})}{s_{x}}\\ &z_{\bar{x}}=&\frac{(x-\mu)}{\frac{\sigma_{x}}{\sqrt{n}}} \\ &t_{\bar{x}}=& \frac{(x-\bar{x})}{\frac{s_{x}}{\sqrt{n}}}\\ \end{aligned} \]

Examples from C.L.T

  • This is a scripting/worksheet homework
  • 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.

Simulations for a Poisson r.v. - 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)

Theoretical setup for simulation

\(Sample_1\) \(Sample_2\) \(\ldots\) \(Sample_K\)
1 \(x_{1,1}\) \(x_{1,2}\) \(x_{1,...}\) \(x_{1,K}\)
2 \(x_{2,1}\)
\(\ldots\)
\(\ldots\)
sample size =n \(x_{n,1}\) \(x_{n,K}\)
\(\bar{X_{1}}\) \(\bar{X_{2}}\) \(\bar{X_{K}}\)

Plots from Simulation, n=5

Plots from Simulation, n=50

Plots from Simulation, n=5 vs 50

  • As sample size increases the distribution of means get more symmetric and averages have a tighter deviation around the mean. Think why that is, hint: \(\frac{\sigma}{\sqrt{n}}\)

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.

Central Limit Theorem (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 with mean \(\mu\) and standard deviation of the averages calculated as \(\frac{\sigma_{X}}{\sqrt(n)}\) if the mean and standard deviation is finite.
  • We use this property to make inferences about averages \((\bar{x},\mu)\).
  • This property is useful because you do not always have to know the shape of the orignal distribution.

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 if sample size is high.
  • This knowledge allows us to make inferences on \(\bar{x}\).
  • If variance of X is 2 than standard deviation is \(\sqrt{2}\).
  • For n=5, which is a very small sample size, standard error is \(\frac{\sqrt{2}}{\sqrt{5}}\)
  • NOTE \(\sqrt{2}\) is in the numerator because we knew the variance of X was 2.

Simulations for \(X\sim Pois.(\lambda=2)\)

\(Sample_1\) \(Sample_2\) \(\ldots\) \(Sample_K\)
1 \(0\) \(2\) \(1\) \(3\)
2 \(5\) \(\ldots\) \(\ldots\) \(2\)
3 \(2\) \(\ldots\) \(\ldots\) \(0\)
4 \(3\) \(\ldots\) \(\ldots\) \(1\)
5 \(1\) \(1\) \(\ldots\) \(4\)
\(\bar{X}\) \(\bar{X_{1}}=1.98\) \(\bar{X_{2}}=2\) \(\bar{X_{K}}=2.2\)
s \(s_{1}=1.92\) \(s_{2}=1.58\) \(s_{K}=2.3\)

Motivation for C.L.T.

  • We can use CLT to either say something about \(\bar{x}\)’s or \(\mu\).

  • We do not need to know the original distribution of X in order to create intervals about average/(s)

  • Confidence Intervals (CI): Create and Upper and Lower Bound to be used to infer where the \(\bar{X}\) or \(\mu\) is going to be.

  • Hypothesis Tests: Make a statement about population mean(s) using information from a sample.

C.I. Known Parameters \(\mu\), \(\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.

Does C.L.T apply here?

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.041
  • when n=5 and \(X\sim Poisson(\lambda=2)\)

  • 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.

  • Numbers much smaller or larger than \(10\%\) indicate that CLT does not apply.

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:

  • 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

  • One use is via 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.

\[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}}\]

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
  • Excel: t.inv(0.95,51)=1.68 ; R: qt(.95,51)=1.68.

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}}\]

Putting it together

  • The confidence interval will give us a good idea about where the population mean is. If we built many \(90\%\) confidence intervals it will contain 90 out of 100 times the population mean.

\[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 and 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 where you have built 100s of confidence intervals.

  • 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.

Questions: 1A

  • The average Australian shepherd lives 13 years long. The \(\sigma\) of their life expectancy is approximately 1.

    1. Can you build a \(99\%\) C.I. for the life expectancy of an Australian Shepherd with what is given to us?
    1. Can you build a \(99\%\) C.I. for the life expectancy of 49 Australian shepherds?
    1. Why can you build a C.I. for A and not B?
    1. An Australian shepherd rescue has recorded a 10 years life expectancy for 49 of their Australian shepherds. Should this rescue be investigated?

Questions: Context 1B

  • The average salary of 121 new Business school undergraduate student from XYZ university is 67,000. The standard deviation of the salaries is 17,000.
  • The average salary of 111 new Business school undergraduate student from ABC university is 49,000. The standard deviation of the salaries is 25,000.

Questions: 1B

  • Build separate confidence intervals for these two universities. XYZ school has a 4 year tuition of 200,000 while ABC has 120,000. What information do you need to know to decide which school you would go to if you get accepted from both universities and you would need student loans to attend college. For this question we are assuming economic outcome is the only thing you care about education which I do not personally subscribe to.

Questions: 2

  • There is a feed that is supposed to increase the life expectancy of dogs. Randomly selected 49 Australian shepherds who have had this feed have an average life expectancy of 13.1 years. What are the other things you need to know in order to decide whether you will buy this feed for your own dogs?

Questions: 3

  • A new edtech software is supposed to increase average student math scores. The historical average score of students is 680. The average score of the 81 students after software has been in use is 695 with a sample standard deviation of 70.

  • Go through each step of the hypothesis test and check whether the new edtech software has increased the average student math score. \(\alpha=0.03\)

  • What issues does this hypothesis test do not resolve?