statr session 15 and 16

Post on 01-Nov-2014

403 Views

Category:

Education

4 Downloads

Preview:

Click to see full reader

DESCRIPTION

Praxis Weekend Business Analytics

TRANSCRIPT

Learning Objectives• Know how to implement the Hypothesis, Test, Action,

Business (HTAB) system to test hypotheses.• Understand the logic of Statistical Hypothesis Testing:

– Know how to establish null and alternative hypotheses– Understand Type I and Type II errors– Calculate the probability of Type II error when failing to reject the null

hypothesis

• Understand how to test a hypothesis about a single population parameter:– Mean

• when s is known (using z-statistic)• when s is unknown (using t-statistic)

Types of Hypotheses1. Research Hypothesis– a statement of what the researcher believes will be the

outcome of an experiment or a study.

2. Statistical Hypothesis– a more formal structure derived from the scientific

method– composed of two parts :

• Null hypothesis (Ho) – the assumed value of the parameter if there is no effect/ impact. We will conclude that this could be true unless there is a small chance of getting a sample statistic (mean/proportion/variance) as extreme or more extreme than from the data (small p-value).

• Alternative hypothesis (Ha) – a statement of whether the true population parameter is higher, lower, or not equal to that hypothesized in the null hypothesis.

Types of Hypotheses

3. Substantive Hypothesis - a statistically significant difference does not imply or mean a material, substantive difference. – If the null hypothesis is rejected and the

alternative hypothesis is accepted, then one can say that a statistically significant result has been obtained

– With “significant” results, you reject the null hypothesis

Using the HTAB System

• H – Hypotheses– Establish the hypothesis

• T – Test– Conduct the test

• A – Action– Take statistical action

• B – Business Implications– Determine the business implications

CPA Salary Example

Example: A survey of CPAs in the U.S., done 15 years ago, found that their average salary was $74,914. An accounting researcher would like to test whether this average has changed over the years. A random sample of 112 CPAs produced a mean salary of $78,695. Assume that the population standard deviation of salaries is = $14,530 (note: this value is typically not known, but we will assume it for mathematical simplicity. Later, we will remove this assumption).

Step 1: Hypothesis

Set up the null and alternative hypotheses

914,74$:914,74$:0

aHH

Always contains “=“

> or < or ≠

Null and Alternative Hypotheses

• The null and alternative hypotheses are mutually exclusive.– Only one of them can be selected.

• The null hypothesis is assumed to be true. It is compared to the observed data via either a critical value (critical value method) or by calculating a p-value (p-value method)

• The burden of proof falls on the alternative hypothesis. Thus, you either reject the null in favour of the alternative or you fail to reject the null in favour of the alternative. The latter statement does not imply that the null is true.

Examples: One-tailed and Two-tailed Tests

• One-tailed Test- Means

- Proportions

• Two-tailed Test

40:

40:0

aH

H

18.0:

18.0:0

pH

pH

a

12:

12:0

aH

H

Step 2: Determine Appropriate Test

• The z-statistic can be used to test m when the following three conditions are met:– The data are a random sample from the population– The sample standard deviation (s) is known– At least one of the following conditions are met:

• The sample size (n) is at least 30 • The underlying distribution is normal

• The value of z-statistic can be calculated using the following formula

xz

n

Finite Population Correction

• If the sample is drawn from a finite population of size N, the formula for z-statistic becomes…

1

NnN

n

Xz

Step 3: Set significance level (a)

• Significance level (a) or Type I error rate– Committed by rejecting a true null hypothesis – If the null hypothesis is true, any value that falls in a

rejection region will represent a Type I error.– The probability of committing a Type I error is

referred to as , the level of significance.

• The significance level is usually set at 0.05. Other common values are 0.1, 0.01, or 0.001.

Type II Errors

• Type II Error– Committed when a researcher fails to reject a false null

hypothesis– The probability of committing a Type II error is referred to as . Some refer to power, or 1- (the chance of rejecting the null when it is false), instead.

• In practice, we do not know whether the null hypothesis is true.

• Type I and Type II error rates are inversely related, if you reduce one, you increase the other.

• One way of reducing both Type I and Type II error rates is to increase the sample size, but that requires more time and money.

Decision Table for Hypothesis Testing

(

( )

Null True Null False

Fail toreject null

CorrectDecision

Type II error )

Reject null Type I error

Correct Decision (Power)

Decision:

State of Null (Truth)

Step 4: Decision Rule

• A decision rule has to be made about when the difference between the sample and hypothesized population mean (under the null hypothesis) is small or large.

• The rejection region is the area on the curve where the null hypothesis is rejected. Here the value of the sample mean is too far from the hypothesized population mean to conclude that they are the same.

• The nonrejection region is the area where the null hypothesis is not rejected. Here the sample mean is close enough to the hypothesized population mean to conclude that the null hypothesis could be true.

Rejection and Non-rejection Regions

=$74,914

Non Rejection Region

Rejection Region

Critical Value

Rejection Region

Critical Value

Decision rule – CPA Example

=$74,914

Non Rejection Region

Rejection Region Rejection Region

Za/2 = Z0.025 = -1.96 Z1-a/2 = Z0.975 = +1.96

Z = 0

Critical Z values:

Level of significance = 0.05

.4750 .4750

X

95%.025.025

Z1.96-1.96 0

= =

=- =

Non-rejection Region

Values of z for common Levels of Confidence

Confidence Level Z Value90% 1.64595% 1.9698% 2.3399% 2.575

Confidence Interval? is Level of Significance in Hypothesis Testing

Decision Rule – CPA Example

Thus, we will reject H0 if Z > 1.96 or Z < -1.96or reject H0 if |Z| > 1.96

Critical Value Based on Sample Mean

Alternatively, you could calculate a critical value based not on Z, but on x-bar.

605,77 and 223,72

691,2914,74112530,1496.1914,74

112530,14914,7496.1

cc

c

cc

xupperxlower

xor

xson

xcz

Thus, we would reject the null if the sample mean is above $77,605 or below $72,223.

One-tailed TestsDepending on the problem, one-tailed tests are sometimes appropriate.

40:

40:0

aH

H

40:

40:0

aH

H

=40 oz

Rejection Region

Non Rejection Region

Critical Value

=40 oz

Rejection Region

Non Rejection Region

Critical Value

Step 5 (Gather Data) andStep 6 (Compute Test Statistic)

• Step 5: Gather the data Suppose that all 112 CPAs responded to the survey. The following summary statistics are calculated:

= $78,695, n = 112, = $14,530 (given)• Step 6: Compute the test statistic

75.2112/14530

7491478695/

n

Xz

Step 7: Statistical Action (Decision)

• The rejection region / rule was: If , reject If , do not reject

• We calculated Z to be 2.75 from our data , so reject

Step 8: Business Decision

Statistically, the researcher has enough evidenceto reject the figure of $74,914 as the true average salary for CPAs. Based on the evidence gathered, it suggests that the average has increased over the 15-year period.

Alternative Method: the p-value• p-value – another way to reach statistical conclusion in

hypothesis testingIf the null hypothesis is true, the p value is the probability of getting a sample mean as extreme or more extreme than what you observed.If the sample mean is in the rejection region, the p-value will be small. These two methods are always consistent.

• p-value < reject H0, p-value do not reject H0

• For two tailed test, a/2 is used in each regionThe p value is then compared to α/2 instead of a to determine statistical significance.Some statisticians (and packages) double the p-value for a two sided test instead and compare to a.

p-value for CPA Example

• In the CPA example, was $78,695, p value = P( > $78,695 | H0 true)

• Since 0.003 < 0.025, we reject the null hypothesis

003.0)75.2(

112530,14$

914,74$695,78$914,74$|695,78$

ZP

n

xPxP

Review of 8 Steps of Hypothesis Testing

1 – Establish the null and alternative hypotheses2 – Determine the appropriate statistical test3 – Set a, the Type I error rate / significance level4 – Establish the decision rule5 – Gather sample data6 – Analyze the data7 – Reach a statistical conclusion8 – Make a business decision

Hypothesis Test of with unknown

The U.S. Farmers’ Production Company (USFPC) builds large harvesters. For a harvester to be properly balanced when operating, a 25-pound plate is installed on its side. The machine that produces these plates is set to yield plates that average 25 pounds. The distribution of plates produced from the machine is normal. However, the shop supervisor is worried that the machine is out of adjustment and is producing plates that do not average 25 pounds. To test this, he randomly selects 20 of the plates from the day before and weighs them.

Hypothesis Test of with unknown • Establish the null and alternative hypotheses

H0: m=25 pounds (where = m mean weight of all plates)Ha: m≠25

• Determine the appropriate statistical test. Recall from earlier session, the conditions for the t-distribution:1. The sample was randomly selected from the population 2. The population standard deviation (s) is unknown3. One of these conditions are met: The sample size (n) is at least 30 OR

the underlying distribution is normalThese conditions are met!The degrees of freedom are n-1 = 20-1 = 19 in this example

Recap: t Distribution

A family of distributions - a unique distribution for each value of its parameter using degrees of freedom (d.f.), every sample size having a different distribution

n

sx

t

Hypothesis Test of with unknown

3 – Set a, the Type I error rate / significance levelSet a = 0.05 (the common default)

4 – Establish the decision ruleUsing the critical value method, we will reject the null if

or tc = ±2.0935 – Gather sample data

From the sample data, = 25.51 and s = 2.19336 – Analyze the data

093.219025.0192/19 ttttt

04.120/1933.2

2551.25/1

nsX

nt

Hypothesis Test of with unknown

7 – Reach a statistical conclusionSince |t| = 1.04 < tc = 2.093, do not reject H0

8 – Make a business decisionThere is not enough evidence to show that the plates are different from 25 pounds. (Note: Is this because the true population mean is close to 25 pounds, or is there a large chance that we have suffered from a Type II error? Good question – more on calculating type II error rates later.)

R: Lower Tail Test of Population Mean when Population Variance is known.

Problem: Suppose a manufacturer claims that the mean lifetime of a light bulb is more than 10,000 hours. In a sample of 30 light bulbs, it was found that they only last 9,900 hours on average. Assume the population standard deviation is 120 hours. At .05 significance level, can we reject the claim by the manufacturer?

Go to http://www.r-tutor.com/elementary-statistics/hypothesis-testing

R: Upper Tail Test of Population Mean when Population Variance is known.

Problem: Suppose the food label on a cookie bag states that there is at most 2 grams of saturated fat in a single cookie. In a sample of 35 cookies, it is found that the mean amount of saturated fat per cookie is 2.1 grams. Assume that the population standard deviation is 0.25 grams. At .05 significance level, can we reject the claim on food label?

Go to http://www.r-tutor.com/elementary-statistics/hypothesis-testing

R: Two-tailed Test of Population Mean when Population Variance is known.

Problem: Suppose the mean weight of King Penguins found in an Antarctic colony last year was 15.4 kg. In a sample of 35 penguins same time this year in the same colony, the mean penguin weight is 14.6 kg. Assume the population standard deviation is 2.5 kg. At .05 significance level, can we reject the null hypothesis that the mean penguin weight does not differ from last year?

Go to http://www.r-tutor.com/elementary-statistics/hypothesis-testing

R: Lower Tail Test of Population Mean when Population Variance is unknown

Problem: Suppose the same manufacturer claims that the mean lifetime of a light bulb is more than 10,000 hours. In a sample of 30 light bulbs, it was found that they only last 9,900 hours on average. Assume the sample standard deviation is 125 hours. At 0.05 significance level, can we reject the claim by the manufacturer?

Go to http://www.r-tutor.com/elementary-statistics/hypothesis-testing

R: Upper Tail Test of Population Mean when Population Variance is unknown

Problem: Suppose the same food label on a cookie bag states that there is at most 2 grams of saturated fat in a single cookie. In a sample of 35 cookies, it is found that the mean amount of saturated fat per cookie is 2.1 grams. Assume that the sample standard deviation is 0.3 gram. At 0.05 significance level, can we reject the claim on food label? Solution

Go to http://www.r-tutor.com/elementary-statistics/hypothesis-testing

R: Two Tail Test of Population Mean when Population Variance is unknown

Problem: Suppose the mean weight of King Penguins found in an Antarctic colony last year was 15.4 kg. In a sample of 35 penguins same time this year in the same colony, the mean penguin weight is 14.6 kg. Assume the sample standard deviation is 2.5 kg. At 0.05 significance level, can we reject the null hypothesis that the mean penguin weight does not differ from last year?

Go to http://www.r-tutor.com/elementary-statistics/hypothesis-testing

R: Two Tail Test of Population Mean when Population Variance is unknown

Go to http://ww2.coastal.edu/kingw/statistics/R-tutorials/index.html

Enter Single Sample t test and practice the t.test() command with the temperature data given

top related