0% found this document useful (0 votes)
13 views102 pages

Biostateunit 3

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 102

What Is Hypothesis Testing in Statistics?

Hypothesis Testing is a type of statistical analysis in which


you put your assumptions about a population parameter to
the test.
It is used to estimate the relationship between 2 statistical
variables.
A hypothesis test (or test of significance) is a standard
procedure for testing a claim about a property of a
population.
Example: An investigator doesn’t know the population mean body
temperature of African elephants, but using current knowledge of the
physiology, surface area, and weight of African elephants, together with
current theory of how these things affect body temperature, he hypothesizes
that it is 96.0◦F. If the mean of a random sample of 50 African elephants is
96.2◦F, does this cast doubt that the current theory is applicable to African
elephants?
Hypothesis testing: Introduction

Confidence intervals are one of the two main currencies of


statistical inference. The other is hypothesis testing.
Briefly, statistical hypothesis testing is a procedure for testing the
validity of a claim about a population parameter by evaluating how
compatible, probabilistically speaking, it is with a relevant statistic
computed from a random sample.
Example: An investigator doesn’t know the population mean body temperature
of African elephants, but using current knowledge of the physiology, surface
area, and weight of African elephants, together with current theory of how these
things affect body temperature, he hypothesizes that it is 96.0◦F. If the mean of
a random sample of 50 African elephants is 96.2◦F, does this cast doubt that the
current theory is applicable to African elephants?
Hypothesis testing: Null and alternative hypotheses

● The Null Hypothesis is the assumption that the event


will not occur.
● The Alternate Hypothesis is the logical opposite of the
null hypothesis.
● The acceptance of the alternative hypothesis follows
the rejection of the null hypothesis.
● H0 and H1 are the symbols for null and alternative
hypothesis.
Hypothesis testing: Null and alternative hypotheses

A sanitizer manufacturer claims that its product kills 95


percent of germs on average.

To put this company's claim to the test, create a null and


alternate hypothesis.
Hypothesis testing: Null and alternative hypotheses

H0 (Null Hypothesis): Average = 95%.

Alternative Hypothesis (H1): The average is less than 95%.


Simple and Composite Hypothesis Testing

Simple Hypothesis: A simple hypothesis specifies an exact


value for the parameter.

Composite Hypothesis: A composite hypothesis specifies a


range of values.
Simple and Composite Hypothesis Testing

Identify the nature of testing

A company is claiming that their average sales for this


quarter are 1000 units of sanitizers

Simple Hypothesis

Suppose the company claims that the sales are in the range
of 900 to 1000 units

Composite Hypothesis
Hypothesis testing: Null and alternative hypotheses

We’ve answered a few questions similar to this in an informal


way. Now, however, we formalize things so that we can test
hypotheses in a consistent, scientifically valid way.
We consider only those situations in which there are two mutually
exclusive and exhaustive hypotheses:

1. Null hypothesis, H0. This is the default, or status quo, claim


about a population parameter.

2. Alternative hypothesis, Ha. Also called the research


hypothesis, this is the scientific investigator’s claim about
the population parameter.
Hypothesis testing: Hypotheses about a population
mean

Hypotheses about a population mean are of 3


types:
• H0: µ = µ0 versus Ha : µ ≠ µ0

• H0: µ ≤ µ0 Ha : µ > µ0

• H0: µ ≥ µ0 versus Ha : µ < µ0


versus

In the first of these, Ha is two-sided; in the others, Ha is one-sided.


Note that µ0 is always included in the null hypothesis.
Hypothesis testing: Null and alternative hypotheses
• The investigator must specify these two hypotheses according
to the problem at hand and his/her goals.
• Depending on their goals, one investigator’s H0 may be differ-
ent than another investigator’s H0, even for the same problem.
• The burden of proof is always on the investigator to provide
strong evidence that the null hypothesis is false (this is consis-
tent with the scientific method).

Example 1 (not biological): A murder is committed, and a suspect is


arrested and put to trial.
The jury’s H0:
The jury’s Ha:
Hypothesis testing: Null and alternative hypotheses
Example 2: Mean body temperature of African elephants. Let µ rep-
resent the mean body temperature for the population of elephants.
The researcher’s H0:
The researcher’s Ha:

Example 3: A new treatment regimen for pancreatic cancer is devel-


oped by researchers. Let p represent the proportion of a conceptual
population of patients receiving the new treatment that will be alive
after 5 years, and suppose that this proportion for the population of
patients receiving the current best treatment is 0.046.
The researcher’s H0:
The researcher’s Ha:
Hypothesis testing: Components
The formal components used in hypothesis testing:
• null hypothesis,
• alternative hypothesis,
• test statistic,
• critical region,
• significance level,
• critical value,
• P-value,
• type I error,
• type II error.
Hypothesis testing: Type I and Type II errors

Based on the evidence, H0 will be either rejected or not rejected


(accepted). This decision can be right or wrong. There are two
types of correct decisions, and two types of wrong decisions
(errors); the latter are called Type I and Type II errors.
Example 1: Jury’s decision about murder suspect

Example 2: Researcher’s decision about population mean body


temperature of African elephants
Hypothesis testing: Type I and Type II errors

Define:

α = Probability of making a Type I error,


β = Probability of making a Type II error.
• In statistical hypothesis testing, we have the ability to set α
at some relatively small number, traditionally at .05 or .01;
then we take what we get for β (generally, the smaller we
make α, the larger that β gets).

• Some situations may call for a larger or smaller α, e.g. des-


perate health situations.

• α is also called the level of significance.


Hypothesis testing: Power

The power of a test is the probability, using that test, that we will
reject H0 when it is false.

• Thus, Power = 1 −β .

• High power is a good thing!

• Some tests have higher power than others, but often at the
price of more restrictive assumptions
Hypothesis testing: Six-step procedure
1. Formulate H0 and Ha, based on the scientific question of
interest.

2. Choose a level of significance, α, based on the relative


importance of Type I and Type II errors in the given
situation.

3. Choose an appropriate test statistic for the problem and


compute it. We generally choose the most powerful test
statistic available, provided that the assumptions required
for its validity are satisfied.

4. (a) Determine a critical value(s), using a table, to which the


test statistic’s value will be compared; OR
(b) Determine the P value, using a table, to compare to α.
Hypothesis testing: Six-step procedure
5. (a) If the test statistic is more extreme than the critical
value(s), then reject H0; otherwise do not reject H0. OR
(b) If the P value is less than α, reject H0; otherwise do not
reject H0.

6. Express your conclusion as an answer to the scientific


question of interest.
Test statistics for hypotheses about a population mean

A test statistic is a quantity, computable from a random sample,


which measures the discrepancy between what the data say about
the population parameter’s value and what H0 claims the
population parameter’s value is.
For testing hypotheses about a population mean µ, this discrepancy
can (initially) be measured by

X − µ0.

However, the “extremeness” of any particular value of this


discrep- ancy cannot be judged until it is scaled by the inherent
variability of the data. So for our test statistic we scale this
discrepancy by the variability of X , or an estimate thereof.
Test statistics for hypotheses about a population mean

According to the CLT, the standard error of X is σ/√n. So, if σ is


known to us, we may use as our test statistic the “z-statistic”

• Dividing by σ/√n calibrates the discrepancy between X and


µ0 in units of standard error.

• Note that if µ really does equal µ0 (i.e. if H0 is true), and if n


is sufficiently large, then by the CLT the distribution of the
z-statistic is approximately N(0, 1).
Test statistics for hypotheses about a population mean

If σ is not known (which is almost always the case in practice),


then we may replace it with s in the z-statistic, yielding as a test
statistic the “t-statistic”

• The discrepancy between X and µ0 is calibrated in units of


estimated standard error.

• If µ really does equal µ0 (i.e. if H0 is true), and if n is


sufficiently large, then the distribution of the t-statistic is
approximately t with n− 1 degrees of freedom.
Critical values for testing hypotheses about a popula-
tion mean

For the t-statistic, critical values are:

• ±t1−α/2,n−1 if Ha is two-sided

• t1−α,n−1 if Ha is µ > µ0

• tα,n−1 if Ha is µ < µ0

If our computed test statistic is more extreme than the critical


value, we reject H0; otherwise, we do not reject H0.
Hypothesis testing for a population mean: Example

A researcher wanted to test the hypothesis that the mean body tem-
perature of African elephants was 96.0◦F. He has no prior notion
about which direction the mean body temperature of elephants will
differ from 96.0◦F if it is not equal to 96.0.

• Step 1. So, letting µ represent the mean body temperature of


African elephants, he wants to test
H0 : µ = 96.0 versus Ha : µ ≠ 96.0.

• Step 2. He makes a traditional choice of α = .05.

A random sample of 50 African elephants is taken, from which the


sample mean and sample standard deviation were computed as fol-
lows: X = 96.2, s = 0.63.
Problems
Null hypothesis

The null hypothesis is a statement that the value of a


population parameter (such as proportion, mean, or
standard deviation) is equal to some claimed value.
Alternative hypothesis

● Statement that the parameter has a value that somehow


differs from the null hypothesis
● the symbolic form of the alternative hypothesis must use
one of these symbols: < or > or ≠
Identifying the Null and Alternative Hypotheses

● The proportion of peas with yellow pods is equal to 0.25


● Ho = 0.25 and H1 ≠ 0.25
● The mean height of an adult male is at most 183 cm
● Ho = 183 and H1 < 183
Null hypothesis
Test statistic is a value computed from the sample data,
and it is used in making the decision about the rejection
of the null hypothesis
Finding the Test Statistic
A genetics experiment results in 580 offspring peas, and
26.2% (or of them have yellow pods. Find the value of the
test statistic for Mendel’s claim that the proportion of
peas with yellow pods is equal to 0.25.
Finding the Test Statistic
A genetics experiment results in 580 offspring peas, and
26.2% (or of them have yellow pods. Find the value of the
test statistic for Mendel’s claim that the proportion of
peas with yellow pods is equal to 0.25.

● Ho = 0.25 and H1 ≠ 0.25


Finding the Test Statistic
A genetics experiment results in 580 offspring peas, and
26.2% (or of them have yellow pods. Find the value of the
test statistic for Mendel’s claim that the proportion of
peas with yellow pods is equal to 0.25.
Finding the Test Statistic
A genetics experiment results in 580 offspring peas, and
26.2% (or of them have yellow pods. Find the value of the
test statistic for Mendel’s claim that the proportion of
peas with yellow pods is equal to 0.25.
Sample proportion of 0.262
does not fall within the
range of values and are
so far away from 0.25 that
they are not likely to occur
by chance
Alternative hypothesis

● The critical region (or rejection region) is the set of all values of
the test statistic that cause us to reject the null hypothesis

● The significance level (denoted by α ) is the probability that the


test statistic will fall in the critical region when the null
hypothesis is actually true.
Finding Critical Values

● Using a significance level of find the critical z values for each of


the following alternative hypotheses
Two-Tailed, Left-Tailed, Right-Tailed

● Two-tailed test: The critical region is in the two extreme regions


(tails) under the curve.
● Left-tailed test: The critical region is in the extreme left region
(tail) under the curve.
● Right-tailed test: The critical region is in the extreme right
region (tail) under the curve.
Two-Tailed, Left-Tailed, Right-Tailed

● In two-tailed tests, the


significance level is divided
equally between the two tails
that constitute the critical
region.

● For example, in a two-tailed


test with a significance level of
there is an area of 0.025 in each
of the two tails
Two-Tailed, Left-Tailed, Right-Tailed

● The P-value ( probability value) is the probability of getting a


value of the test statistic that is at least as extreme as the one
representing the sample data
● The null hypothesis is rejected if the P-value is very small, such
as 0.05 or less.
Finding P-Values

a)P-value is the area to the right of the test statistic


area to the right of is z = 2.34 is 0.0096
p<α
we reject the null hypothesis.
Finding P-Values
Decision Criterion for hypothesis testing
Decision Criterion for hypothesis testing

P-value
● The P-value is known as the probability value.
● represents the probability of occurrence of the given event
● If the P-value is small, then there is stronger evidence in
favour of the alternative hypothesis
Decision Criterion for hypothesis testing
Decision Criterion for hypothesis testing

P-value is 0.3105. If the level of significance is 5%, find if we


can reject the null hypothesis

the p-value of 0.3105 is greater than the level of significance


of 0.05 (5%), we fail to reject the null hypothesis.
Decision Criterion for hypothesis testing

P-value is 0.0219. If the level of significance is 5%, find if we can


reject the null hypothesis

Looking at the P-value table, the p-value of 0.0219 is less than the
level of significance of 0.05, we reject the null hypothesis.
Decision Criterion for hypothesis testing

The store launched a glucose monitoring device. They had run a


marketing campaign for 100 days to promote the product. The
store claimed that the average number of device sold was 500
units per day during the 100 days of the marketing campaign.
Decision Criterion for hypothesis testing

5 sample datasets from the entire dataset of the campaign. Each


sample has data of 15 days

Sample_1 : 535.5
Sample_2 : 495.2
Sample_3 : 510.5
Sample_4 : 497.7
Sample_5 : 504.3

Validate Sample 1 using the p-value method. the threshold or the


significance level of 0.05 (5%)
Decision Criterion for hypothesis testing

Null Hypothesis (H0) : Average product sold is 500

Alternate Hypothesis (H1) : Average product sold is


not 500 Population Mean : 500
Population Standard Deviation : 45
Sample Mean (Sample_1) : 535.5
Sample Size (Sample_1) : 15
Alpha (Significance Level) : 0.05 (2-
tailed Test)
Decision Criterion for hypothesis testing
Z-value 3.05
P-value = 1 - Prob(Z-score)
P-value = 1 - 0.99886
P-value = 0.001

P-value = 0.001 * 2
P-value = 0.002
problem statement and the hypothesis, finding a sample mean
value of 535.5 has a probability of 0.002 or 0.2%, which is
extremely less than the significance level (0.05 or 5%) and is
considered too far away from the population mean (500).

we Reject The Null Hypothesis.


The fatality rate of the typhoid patients is found to be 17.26%. In a certain year 640 patients
suffering from typhoid were treated in a hospital and only 63 patients died. Can you consider
the hospital efficient?
P=0.1726
p=63/640
q=1-p
n=640

Assume LOS to be 1%, therefore Zα=-2.33

Z=-4.96
Z> Zα
The null hypothesis is rejected and the hospital is efficient in bringing down the fatality rate.
The statistical tests enables us to make decisions on the basis of observed pattern from data. There is
a wide range of statistical tests. The choice of which statistical test to utilize relies upon the
• structure of data
• the distribution of the data
• variable type.
Parametric tests are used if the data is normally distributed.
A parametric statistical test makes an assumption about the population parameters and the
distributions that the data came from.
These types of test includes
• t-tests,
• z-tests
• anova tests, which assume data is from normal distribution.

Non parametric statistical test:


Non parametric tests are used when data is not normally distributed. Non parametric tests include chi-
square test.

Chi-square test( χ2 test)- chi-square test is used to compare two categorical variables. Calculating the
Chi-Square statistic value and comparing it against a critical value from the Chi-Square distribution allows
to assess whether the observed frequency are significantly different from the expected frequency.
Z-test- A z-test is a statistical test used to determine whether two population means are
different when the variances are known and the sample size is large. In z-test mean of the
population is compared. The parameters used are population mean and population standard
deviation. Z-test is used to validate a hypothesis that the sample drawn belongs to the same
population.

T-test-In t-test the mean of the two given samples are compared. A t-test is used when the
population parameters (mean and standard deviation) are not known. There are different
categories including: one sample t-test, independent t-test, paired t-test.

Analysis of variance (ANOVA) is a statistical technique that is used to check if the means
of two or more groups are significantly different from each other. ANOVA checks the
impact of one or more factors by comparing the means of different samples. If we use a t-test
instead of ANOVA test it won’t be reliable as number of samples are more than two and it will
give error in the result.
P-Value Method: Data Set lists a sample of 106 body temperatures having a mean of Assume that
the sample is a simple random sample and that the population standard deviation s is known to be
Use a 0.05 significance level to test the common belief that the mean body temperature of healthy
adults is equal to 98.6F.
n=106
Sample mean=98.2
Standard deviation=0.62
Testing one population mean:
T-test statistic
This test is used when the variable is numerical and only one population or group is being
studied. For example, Dr. Phil says that the average time that working mothers spend talking
to their children is 11 minutes per day.
Conditions to be met:
• σ known (not from data)
• Population approximately Normal or large sample (central limit theorem)
• Data valid
Steps to be followed:
• In the 1970s, 20–29 year old men in the U.S. had a
mean μ body weight of 170 pounds. Standard
deviation σ was 40 pounds. We test whether mean
body weight in the population now differs
1. Null hypothesis H0: μ = 170 (“no difference”)
2. The alternative hypothesis can be either
Ha: μ > 170 (one-sided test) or
Ha: μ ≠ 170 (two-sided test)
3.

x  0
z stat 
SE x
where  0  population mean assuming H 0 is true

and SE x 
n
4. Finding the P-value: What is the probability of the
observed test statistic or one more extreme when H0 is
true?
• This corresponds to the AUC in the tail of the Standard
Normal distribution beyond the zstat.
• Convert z statistics to P-value :
For Ha: μ > μ0  P = Pr(Z > zstat) = right-tail beyond zstat
For Ha: μ < μ0  P = Pr(Z < zstat) = left tail beyond zstat
For Ha: μ μ0  P = 2 × one-tailed P-value
If we found a sample mean of
185, then Zstat = 3

One sided P- value:

Two sided P- value:


Interpretation
P > 0.10  non-significant evidence against H0
0.05 < P  0.10  marginally significant evidence
0.01 < P  0.05  significant evidence against H0
P  0.01  highly significant evidence against H0

Examples
P =.27  non-significant evidence against H0
P =.001  highly significant evidence against H0
Reject H0 when P ≤ α
Retain H0 when P > α
Set α = .10.
For P = 0.27  retain H0
For P = .001  reject H0
Testing one population proportion
• This test is used when the variable is categorical (for example, gender or political
party) and only one population is being studied (for example, all U.S. citizens).
• The test is looking at the proportion (p) of individuals in the population who
have a certain characteristics.
• For example, the proportion of people who carry cellphones.
• Suppose Cavifree toothpaste claims that four out
of five dentists recommend Cavifree toothpaste to
their patients. In this case, the population is all
dentists, and p is the proportion of all dentists who
recommended Cavifree to their patients. The claim
is that p is equal to “four out of five,” which means
that po is 4 / 5 = 0.80. You suspect that the
proportion is actually less than 0.80.
• Your hypotheses are Ho: p=0.80 versus
• Ha: p <0.80.
• Suppose that 150 out of 200 dental patients
sampled received a recommendation for Cavifree.
Test statistic comparing two
population means
• This test is used when the variable is numerical (for
example,income, cholesterol level, or miles per gallon) and
two populations or groups are being compared (for
example, cars versus
• SUVs).
• Two separate random samples need to be selected, one
from each population, in order to collect the data needed
for this test.
• The null hypothesis is that the two population means are
the same; in other words, that their difference is equal to 0.
• The notation for the null hypothesis is

Testing the mean difference Paired data
• This test is used when the variable is numerical (for example,
• cholesterol level or miles per gallon), and the individuals in the
sample are either paired up in some way (identical twins are
often used) or the same people are used twice (for example,
using a pretest and post-test).
• Paired tests are used for comparisons where you want to
minimize the chance of the treatment and control groups being
too different (and hence biased).
• Testing paired data amounts to testing one population mean,
where the null hypothesis is that the mean (of the paired
differences) is 0, and the alternative hypothesis is that the mean
(of the paired differences) is greater, lesser or not equal to 0.
Chi-Square Test

● Data analysis on the basis of observations of a random set of


variables.
● It is a comparison of two statistical data sets.
● This test was introduced by Karl Pearson in 1900.So it was
mentioned as Pearson’s chi-squared test.
Chi-Square Test
● It calculates the difference between observed and expected
data values.
● It is used to find out how closely actual data fit with expected
data.
Problem

The number of automobile accidents per week in a certain


highway were as follows: 12, 8, 20, 2, 14, 10, 15, 6, 9, 4

Are these frequencies in agreement with the belief that


accident conditions were the same during this 10-week
period? At α = 0.01
Solution

Null Hypothesis: number of accidents per week are same during


the 10-week period.
Alternate Hypothesis: number of accidents per week are different
during the 10-week period
Solution

Since the total number of accidents over the 10 weeks are:

12 + 8 + 20 + 2 + 14 + 10 + 15 + 6 + 9 + 4 = 100

expected number of accidents for each of the 10 weeks are 100/10


= 10
Solution
O E (O-E) (O-E)^2 (O-E)^2/E
Solution

χ2 = 26.6 is greater than the tabulated value, 21.666.

It is significant and the null hypothesis rejected at .01 level of


significance. Hence we conclude that the accident conditions are
certainly not uniform over the 10-week period.
Problem

In an experiment on breeding of peas a researcher obtained


the following data: The theory predicts the proportion of
beans, in four groups A, B, C and D should be 9: 3: 3: 1.

In an experiment among 1,600 beans, the numbers in four


groups were 882, 313, 287 and 118.

Does the experiment results support the genetic theory?


(Test at .05 level)
Solution

Null Hypothesis: no significant difference between the


experimental values and the theory.
Alternate Hypothesis: significant difference between the
experimental values and the theory.
Solution

In an experiment on breeding of peas a researcher obtained


the following data: The theory predicts the proportion of
beans, in four groups A, B, C and D should be 9: 3: 3: 1.

In an experiment among 1,600 beans, the numbers in four


groups were 882, 313, 287 and 118.

Does the experiment results support the genetic theory?


(Test at .05 level)
Solution
Solution

● χ2 value of 4.726
Solution

● χ2 value of 4.726 < 7.81, it is not significant.


● Hence null hypothesis may be accepted at .05 level of
significance
● conclude that the experimental results support the genetic
theory.
What is type I error?
List the different types of statistical tests along with the conditions to be met.
ANOVA TEST
• Analysis of variance (ANOVA) is a method of testing the equality
of three or more population means by analyzing sample
variances.
• Analysis of variance (ANOVA) is based on a comparison of two
different estimates of the variance.
• The ANOVA methods require the F distribution,which has the
following
• important properties
• 1. The F distribution is not symmetric; it is skewed to the right.
• 2. The values of F can be 0 or positive, but they cannot be
negative.
• 3. There is a different F distribution for each pair of degrees of
freedom for the numerator and denominator.
• In general, as we increase the number of individual tests of significance, we
increase the likelihood of finding a difference by chance alone (instead of a real
difference in the means).
• The risk of a type I error—finding a difference in one of the pairs when no such
difference actually exists—is far too high.
• The method of analysis of variance helps us avoid that particular pitfall
(rejecting a true null hypothesis) by using one test for equality of several
means.
One way and two way ANOVA
The term one-way ANOVA is used because the sample
data are separated into groups according to one
characteristic, or factor.
• For example, the weights summarized in Table 11-1 are
separated into four different groups according to the
one characteristic (or factor) of treatment (none,
fertilizer, irrigation, fertilizer and irrigation).
• In two-way analysis of variance, which allows us to
compare populations separated into categories using
two characteristics (or factors).
• For example, we might separate weights of poplar trees
using the following two factors: (1) site location (moist
or dry) and (2) treatment (none, fertilizer, irrigation,
fertilizer and irrigation).
Sample 1 Sample 2 Sample 3
7 6 4
3 5 7
6 5 6
Variance
between
6 8 7samples
Mean 5.5 6 6 0.288675 0.083333
Standard deviation, σ 1.732051 1.414214 1.414214
Variance within samples, σ2 3 2 2
Two way ANOVA
Example
• Three different kinds of food are tested on three groups of rats for 5
weeks. The objective is to check the difference in mean weight(in grams)
of the rats per week. Apply one-way ANOVA using a 0.05 significance level
to the following data:
• Solution: F=9.33
CORRELATION AND REGRESSION
 Correlation analysis is used to measure the strength
of the association (linear relationship) between two
variables
 Correlation is only concerned with strength of the
relationship
 No causal effect is implied with correlation
 A scatter plot can be used to show the relationship
between two variables
Correlation co-efficient calculation
Example 1:
• Suppose you have the data set
(3, 2), (3, 3), and (6, 4).
• Following the preceding steps, calculate the
correlation coefficient r.
Solution
 Regression analysis is used to:
 Predict the value of a dependent variable based on the
value of at least one independent variable
 Explain the impact of changes in an independent
variable on the dependent variable
 Dependent variable: the variable we wish to
predict or explain
 Independent variable: the variable used to
predict or explain the
dependent variable
Simple Linear Regression Model
• Only one independent variable,
X.
• Relationship between X and Y
is described by a linear function.
• Changes in Y are assumed to be
related to changes in X.
Regression models
Finding the regression line
• Find the regression equation for the data
given below:

You might also like