S371: Lab 9

Lab Instructor: Katya Baldina ()

2023-10-18

Announcement

TEST II OPENED TODAY AT 12.45 PM AND DUE TOMORROW 11.59 PM!

No office hours during the test. If you find anything weird about the test, feel free to email me or Prof. Schultz.

Test II: Multiple Choice

Canvas system does not allow you to go back to the previous question and change the answer

• You can only re-enter all answers in the multiple-choice section from the beginning

• So try to jot down your answer for multiple-choice questions on a piece of paper in case you need to change any answers

Concepts

You have to know how to state your null and test hypotheses

You have to know what is the relationships between critical values, precision, and width of the interval

Hint:

higher your critical value, interval is wider, precision is lower (because there is more possible range of values that might be your population statistic);

lower critical value gives you narrower interval and more precision, but the chance of the error is higher (90%CI vs. 95%CI vs. 99%CI)

Concepts

Concepts

Population SD is given: USE Z TEST

Population SD is not given: USE T TEST

Don’t forget to take one degree of freedom from the sample size when find t statistic from t table

(Hint: what does sample size increase does to the distribution?)

p-value

We can define p-value as:

Assuming that the null hypothesis is true (let’s say H0: µ=10), what is the chance that we draw a random sample and get a sample mean different than that?

\[H_0:m=10\]

\[H_a:m≠10 (two-sided)\]

x = rnorm(1000, 10, 2)
mean(x)
## [1] 9.927614
t.test(x, mu = 10, alternative = "two.sided")
## 
##  One Sample t-test
## 
## data:  x
## t = -1.1566, df = 999, p-value = 0.2477
## alternative hypothesis: true mean is not equal to 10
## 95 percent confidence interval:
##   9.804804 10.050424
## sample estimates:
## mean of x 
##  9.927614

alpha vs. p-value

Alpha:

• The maximum risk we are willing to take (usually 5% or 0.05), given that the null hypothesis is true

P-value:

• The actual risk we are taking, given that the null hypothesis is true

• Put it graphically, it is the area under the curve at the two tails

Desicion Rule

Using the “standard” normal graph, you comparing your actual z-statistic with the alpha corresponding z-statistics:

α=0.10 –> Z= +/-1.64

α=0.05 –> Z= +/-1.96

α=0.01 –> Z= +/-2.58

If your z-statistic is larger than the positive location (1.96) or smaller than the negative location (-1.96) in the “standard” graph, you reject the null hypothesis (otherwise, you fail to reject the null hypothesis)

Decision Rule

In summary, there are two ways to make decision about your hypothesis:

1st way:

If z-statistic>1.96 or z-statistic<-1.96, you reject the null hypothesis

2nd way:

If p-value<0.05 (area under the curve in the two tails<0.05), you reject the null hypothesis

Decision rule

Example 1:

• You want to test if the population mean of a certain variable is 0 or not.

• You collect data by random sampling.

• You plug in the sample mean and standard deviation into the one-sample z-test formula

• The z-statistic is 2.83

Decision rule

Put it graphically:

Is your z-statistic larger OR smaller than the positive location (1.96) on the “standard” graph?

Decision rule

Example 1:

• The z-statistic is 2.83, which is larger than 1.96

–> So the null hypothesis is rejected

• Alternatively, the p-value is 0.0047, which is smaller than 0.05

–> So the null hypothesis is rejected

Decision rule

Example 2:

• You want to test if the population mean of a certain variable is 0 or not.

• You collect data by random sampling.

• You plug in the sample mean and standard deviation into the one-sample z-test formula

• The z-statistic is 1.35

Decision rule

Should you reject the null hypothesis? Why?

One-sample t-test

Goal of the test: Based on the limited size sample, we want to test if the population mean equals to a specific value

Test statistic (helps us to determine whether we should reject the null hypothesis):

\[t = \frac{\bar{x}-\mu_0}{\frac{s}{\sqrt{n}}}\]

Where x-bar is sample mean, mu0 is the hypothesized mean, s is the sample standard deviation, and n is the sample size.

One-sample t-test

Procedure:

  1. State the null and alternative hypotheses

  2. Compute the test statistic (z-statistic or t-statistic, depending on if you are given sample SD or population SD)

  3. Check if the z value falls into the extreme end(s) of the normal distribution

  4. State conclusion in reference to null hypothesis

  5. Interpret in reference to alternative hypothesis

One-sample t-test

Step 1: state the null hypothesis and alternative hypothesis

Let the hypothesized mean be x

• In notation:

\[H_0:\mu=x\]

\[H_a:\mu≠x\]

You read this as:

• Null hypothesis: The mean of XXX equals to x.

• Alternative hypothesis: The mean of XXX does not equal to (differs from) x.

One-sample t-test

Step 2: Compute the test statistic (z-statistic OR t-statistic depending on what you are given in the problem: population or sample SD)

\[t = \frac{\text{sample mean}-\text{hypothesized mean}}{\frac{\text{sample SD}}{\sqrt{\text{sample size}}}}\]

\[t = \frac{\bar{x}-\mu_0}{\frac{s}{\sqrt{n}}}\]

One-sample t-test

In step 3:

  1. Compare your z-statistic with the z* (1.96) or

  2. Compare your p-value with the α (0.05)

• Refer to the decision rule section above.

One-sample t-test

Step 4: State conclusion in reference to null hypothesis

• Just state whether you reject or fail to reject the null hypothesis

• Example: The null hypothesis is rejected at α (usually 0.05) level.

• Refer to the decision rule section above.

One-sample t-test

Step 5: Interpret in reference to alternative hypothesis

• The mean (the meaning of the variable) of (population) (differs/does not differ) significantly from (specified value, x).

One-sample t-test: Example

A random sample of 1000 people is collected. The sample mean of family income (for all Americans) is 53,610. The sample standard deviation is 2,057. Someone claims that the population mean should be 50,000. Do you think that make sense based on the sample data?

One-sample t-test: Example

• State the null and alternative hypotheses.

• Compute the test statistic (z-statistic).

• Does the z-statistic higher or low than the z*?

• What is the p-value?

• Should you reject the null hypothesis?

• Please interpret the result in reference to alternative hypothesis.

One-sample t-test: Example

Step 1:

• In notation:

\[H_0:\mu=50000\]

\[H_a:\mu≠50000\] • In sentences:

• Null hypothesis: The mean income of all Americans equals to 50000.

• Alternative hypothesis: The mean income of all Americans does not equal to 50000.

One-sample t-test: Example

Step 2: Compute the test statistic (z-statistic)

\[t = \frac{\text{sample mean}-\text{hypothesized mean}}{\frac{\text{sample SD}}{\sqrt{\text{sample size}}}}\]

\[t = \frac{\bar{x}-\mu_0}{\frac{s}{\sqrt{n}}}\]

\[t = \frac{53610-50000}{\frac{2057}{\sqrt{1000}}}=55.50\]

One-sample t-test: Example

Does the z-statistic higher or low than the z*?

What is the z*?

• For a critical value of 0.05, the z* is 1.96

• Ask yourself two questions:

Is the z-statistic larger than z*?

Is your z-statistic smaller than the negative of z*?

• Yes to the first question–> reject the null hypothesis

One-sample t-test: Example

What is the p-value?

• From the z-table, since the z-statistic is 55.50, (the area under the curve multiplies by 2) p-value is much smaller than 0.05

Should you reject the null hypothesis? Yes.

One-sample t-test: Example

Please interpret the result in reference to alternative hypothesis.

• The mean family income of all Americans differs significantly from 50,000.