Notes
Notes
Week 1
Statistics tries to explain random phenomena, based on observations of a limited sample material.
Mathematical statistics is a subfield of statistics, where the aim is to develop and improve statistical
methods.
Applied statistics is a subfield of statistics, where the aim is to apply the methods established by
mathematical statistics to related areas.
Biostatistics is a specific branch of applied statistics, where the aim is to apply the methods
established by mathematical statistics to medical and biological problems.
Most of the time, the first step of a statistical analysis is to summarize the data in hand with several
descriptive statistics, in an effort to have a basic understanding about what is being dealt with.
Inferential statistics deals with the problem of revealing the information about the population, by
analyzing the limited sample data.
Measures of Location
Measures of location are numerical descriptive statistics that are used to characterize the center, or
the middle of the sample data.
It is defined as:
n
1
x= ∑x
n i=1 i
Note1: The Σ (sigma) character is the summation sign. If a and b are integers, where a < b, then:
b
∑ x i=x a + x a +1+ …+ x b
i=a
∑ cx i=c (∑ x i)
i=a i=a
Arithmetic mean is a very natural measure of location. However, it is very sensitive to extreme values,
and may not always indicate the location where most of the sample points are aggregated.
In extreme cases, only one sample point may be on the one side of the arithmetic mean, while all the
rest are on the other side.
Although in these cases the arithmetic mean is a poor measure of central location, it is still the most
commonly used one.
The Median:
The median, or more precisely the sample median, is an alternative measure of location. For a
sample set consisting of n observations, which are ordered from smallest to largest, the median is
defined as:
However, it is also insensitive to actual numerical values of the data points, since it is defined by the
middle points in the sample.
If a distribution is symmetrical, the relative position of the points on each side of the sample median
is the same. Also, the arithmetic mean is roughly equal to the sample median.
If a distribution is positively skewed (right-skewed) the points above the median tend to be farther
from the median in absolute value than points below the median. Also, the arithmetic mean tends to
be greater than the sample median.
If a distribution is negatively skewed (left-skewed) the points below the median tend to be farther
from the median in absolute value than points above the median. Also, the arithmetic mean tends to
be less than the sample median.
The Mode:
The mode is another widely used measure of location. It is defined as the most frequently observed
value in the sample.
If the number of possible values in a given sample are large, and each value is infrequently repeated;
then the mode either will not represent the center of the sample, or it may not even exist.
If the data is in the form of exponential numbers, for example the growth of a bacterial culture
doubling after every time interval t, the arithmetic mean will not be as useful, since the data will be
strongly skewed.
In this case the logarithm of each value can be calculated, to obtain more equally spaced sample
points with a weaker skew, and then the arithmetic mean can be calculated. However, it is more
convenient to take the antilogarithm of this result, to keep working in the original scale. Thus, the
geometric mean can be defined as:
√n x i∗x i+1∗…∗x n
The result of geometric mean is the same regardless of the base of the logarithm. However, the same
bases should be used for the log and antilog steps. Commonly used bases are base e, and base 10.
Measures of Spread
Measures of spread describe the variation in the data. Many samples can be well described by a
combination of a measure of location and a measure of spread.
The Range:
The range is the difference between the largest and the smallest observations in the sample.
It can be easily calculated when the sample points are ordered, however it is extremely sensitive to
outliers.
Moreover, it depends on the sample size, as the larger the sample size the greater the range tends to
be. Thus, it is hard to compare the ranges of the samples with differing sizes.
Deviation is the distance of each value to the center of the sample, or to the sample mean.
If the deviation of each value is summed up to summarize the spread of the sample, the following
would be obtained:
n
1
d= ∑ (x ¿−x )=0 ¿
n i=1 i
Because, mean defined as the value which is equally distant from each data point in the sample.
Thus, the sum of the deviations of each data point in the sample around the sample mean is always
zero, and d is not usable as a measure of spread.
Finally, the square root of the sample variance gives the sample standard deviation:
√
n
1
s= ∑ ( x −x )2= √ s2
n−1 i=1 i
How does the variance and the standard deviation respond to translation of the data?
The arithmetic mean and the standard deviation are the most commonly used measures. An
important reason why is that the normal distribution is defined specifically by these two parameters,
and the normal distribution has wide applications in biological and medical settings.
The coefficient of variation is used to relate arithmetic mean and the standard deviation, and
compare the spread of samples with different means. Because, a higher variation is expected with a
higher mean, and CV accounts for this when two samples with different means are compared. CV is
also useful to compare the reproducibility of different variables.
100∗s
CV =
x
Quantiles:
Quantiles are an alternative way to quantify the spread of a data. A q-quantile divides sorted data
into q parts. The pth q-quantile of a sample of n observations is defined as:
th n∗p
1. ( k +1 ) largest value if
is not anintager .
q
n∗p
(Where k is the largest intager less than )
q
2. The average of
n∗p
q ( ) (
th∧
np
q )
+1 thlargest values if
n∗p
q
is anintager .
The spread of a sample can be characterized as the difference between two q-quantiles, in a sorted
data in ascending order, for example, 90th and 10th percentiles (or 100-quantiles).
When this is applied on 3rd and 1st quartiles (or 4-quntiles), this is called The Interquartile Range
(IQR), or middle spread, or middle fifty.
Compared to the range, the quantiles are less sensitive to outliers, and are not affected as much by
the sample size (n).
It may be hard to order large samples before calculating quantiles. However, stem-and-leaf plot may
be helpful for this purpose.
Specialized Quantiles:
A frequency distribution is an ordered display of each value in a data set along with the number of
times that value occurs in the data set. The percentage of sample points that take on a particular
value is also usually given.
If the number of unique values is large in a data set, a frequency distribution can still be too detailed.
In this case, the data can be grouped/binned into broader categories, as follows:
1. Subdivide the data into k intervals, starting at a lower bound y1 and ending at an upper bound
yk+1. (The number of groups will be one less than the number of unique values.)
2. The first interval is from y1 inclusive to y2 exclusive; the second interval is from y2 inclusive to
y3 exclusive; …; the kth interval is from yk inclusive to yk+1 exclusive. (The group intervals will
include all the possible values, and will not overlap.)
3. Intervals are generally equal, although it depends on the subject-matter.
4. For each interval, the number of points that fall into the interval, that is the frequency of that
interval, are counted.
5. The group intervals are then displayed in a table, or plot.
Graphic Methods
Graphics methods are handy to give a quick overall impression of the data, when it is not so easy to
achieve with the numerical measures.
The material must be sufficient enough by itself for viewers to understand without reading
any text.
Clear labelling of attributes.
The quantity of the material displayed should be neither too few, nor too many.
Bar Graphs:
Bar graph is one of the most commonly used method for displaying grouped data.
Stem-and-Leaf Plots:
In the bar graphs; (1) the definition of groups is arbitrary, and (2) the actual sample points are lost
within the groups.
Stem-and-leaf plot is a graphical method that can work around these problems. To construct a stem-
and-leaf plot:
1. Separate each data point into a stem component and a leaf component, where the stem is all
but the rightmost digit of the value, and the leaf is the remaining rightmost digit.
2. Place the smallest stem to the top-left corner of the plot.
3. Place the next smallest stem under the previous one.
4. Repeat step 3 until the largest stem is placed.
5. Draw a vertical line to the right of the stems column.
6. Foreach value in the dataset, the leaves are placed to the right of the vertical line at the level
of their stem, in ascending order.
The leaves show the general form of the distribution of the sample points, and the actual values are
also visible while the data is displayed in groups.
In some variations, leaves can consist of more than one digit, and the digits of the same leaf are
underlined. Also, if the number of leaves is large, each stem can get more than one line in the plot.
Moreover, the order of stems can be reversed.
Finally, a multiplication factor (m) can be added to the bottom of the plot, to allow representation of
decimal numbers. If m is present, the numbers assumed to be in the form of [Link] * 10m.
Histogram:
A box plot uses the relative positions of median, upper quartile and lower quartile to display the
skewness of a distribution.
1. For a symmetrical distribution, the upper and lower quartiles will be roughly equally
distanced from the median.
2. For a positively skewed distribution, the lower quartile will be closer to the median than the
upper quartile.
3. For a negatively skewed distribution, the upper quartile will be closer to the median than the
lower quartile.
Also, the difference between upper and lower quartiles (Q3 – Q1, IQR) can be used to describe the
spread of the data.
Outliers:
However, these definitions for outliers and extreme values are sensitive to sample size. The larger the
sample size, the greater the number of outliers and/or extreme values.
1. Draw three parallel horizontal lines: the first for the upper quartile, the second for the
median, and the third, the bottom-most, for the lower quartile. (The data is being
represented in descending order from top to bottom.)
2. Draw two parallel lines, perpendicular to the horizontal lines, connecting the ends of the
horizontal lines. (This completes the box.)
3. Based on the definition above, draw a perpendicular line from the upper quartile to the
largest non-outlying value; and a perpendicular line from the lower quartile to the smallest
non-outlying value. (This completes the whiskers.)
4. Then, represent the outliers with “o” and extreme values with “x” if any.
The whiskers can also be drawn to represent the range, 2nd and 98th percentiles, or standard
deviation. Then, the data points outside of the whiskers, if any, would be outliers.
In a variable width box plot, the width of the box, w, is proportional to the sample size, n. Usually,
the relationship is in the form of:
w=√ n
In a notched box plot, the box has a notch (narrowing) of height, nh, proportional to the IQR, and
inversely proportional to the sample size. Usually, the relation shape is in the form of:
1.5∗IQR
nh=±
√n
If the notches of two box plots overlap, that means the difference between their medians is not
expected to be significant.
Violin plot:
A violin plot is another tool to display the distribution of data. It is in the form of a distribution
rotated 90° and mirrored along the vertical axis.
Other Pots:
Week 2 + 3
Sample Space: All possible outcomes.
0 ≤ P( E )≤ 1
Events A and B are mutually exclusive if they cannot happen at the same time.
A ∪ B= A∨B
A ∩ B= A∧B
A∧B are independent events ,if :
P ( A ∩B )=P ( A )∗P ( B )
Multiplication Law of Probability:
Conditional probability is helpful when we want to calculate the probability of several dependent
events occurring simultaneously.
P(A∩B)
Conditional probability of B given A is denoted by , P ( B| A )=
P( A)
If A∧B are independent , then P ( B| A )=P ( B )=P ( B| A ) If A∧B are dependent , then
'
P ( B| A ) ≠ P ( B ) ≠ P ( B|A ' ) For any events A∧B , P ( B )=P ( B| A )∗P ( A ) + P ( B| A' )∗P ( A ' )
The relative risk of B given A is , P ( B| A ) / P ( B| A ' )
A set of events A1, A2, …, Ak are exhaustive, if at least one of these events must occur. In other
words, no events in the universe except from these.
Total-Probability Rule:
Let A1, A2, …, Ak be mutually exclusive and exhaustive events. P(B) can be defined as a weighted
average of p(B|Ai) with weight as P(Ai).
k
P ( B )=∑ P ( B|A i )∗P ( A i )
i=1
Bayes’ Rule:
The higher the PVs of a test, the more reliable the test is.
Predictive Value Positive, P(B|A), can be described based on Sensitivity, P(A|B) and Specificity, (A’|
B’) terms.
P( A ∩B)
+¿= P ( B|A ) = ¿
Let A be the test ∧B be the condition: If we substitute ,
P(A)
PV
P ( A ∩B ) → P ( A|B )∗P ( B ) , [ ¿ definition of cond . prob. ]∧¿
P ( A ) → P ( A|B )∗P ( B ) + P ( A|B' )∗P ( B' ) , [ ¿ total prob . rule ] we get :
P ( A|B )∗ P ( B )
+¿= P ( B|A ) = ¿
P ( A|B) ∗P ( B) + P ( A|B )∗ P (B )
' '
PV
If we express the final equation in words:
Sensitivity∗x
Predictive Value Positive=
Sensitivity∗x + ( 1−Specificity )∗( 1−x )
Similarly, Predictive Value Negative would be:
P(B ∩ A ) P ( A |B )∗P ( B )
' ' ' ' '
−¿=P ( B |A )= −¿=P ( B |A )=
' ' ' '
¿ ¿
P( A ) P ( A |B )∗P ( B )+ P ( A |B )∗P ( B )
' ' ' ' '
PV PV
Specificity∗( 1−x )
Predictive Value Negative=
Specificity∗(1−x )+ ( 1−Sensitivity )∗x
Generalized Bayes’ Rule:
P ( A|Bi )∗P ( B i)
P ( B i| A ¿= k
In the Baye’s Rule Formula, for a condition B and a test A,
∑ P ( A∨B j )∗P(B j ¿)¿
j =1
The term P(Bi) is also called the Prior Probability. That is the probability of a condition occurs,
guessed by the observer, without data. Can be a single number or a range of values possibly with a
weight for each one.
The term P(Bi|A) is also called the Posterior Probability. That is the probability of a condition
determined after collecting empirical data. It is obtained by relating additional data to the
information from the prior probability.
In other words, we update our knowledge on the probability of a condition, based on new data.
Sometimes a test may yield multi-categorical results, instead of simple positive and negative. Or the
result may be a continues variable. In these cases, an arbitrary cut-off point is necessary to assess
the result as positive or negative.
ROC curve is a plot of sensitivity on the y-axis versus (1- specificity) on the x-axis. Each point
corresponds to a cut-off point.
The area under the ROC curve is used to summarize the accuracy of the test. (Calculated with
trapezoidal rule)
In general, larger area means more accurate test. Unless some specific sensitivity or specificity values
are important for the test.
Week 4
Discrete Probability Distributions
Permutation: It gives the number of ways to choose n items out of k, when the order of items is
important.
n!
n P k=
( n−k ) !
Combination: It gives the number of ways to choose n items out of k, when the order of items is
NOT important.
()
n!
n Ck = n =
k k ! ( n−k ) !
A feature of combination is:
n Ck =n C n−k
A random variable is a function that that assigns values to different events in a sample space.
If there are a discrete set of values that can be assigned; such as 1, 2, 3, … but nothing in between
them; then the random variable called a discrete random variable.
On the other hand, if the possible values of a random variable cannot be enumerated; such as [0,1]
interval, which has infinite number of values in between 0 and 1; then the random variable is called a
continuous random variable.
A probability-mass function, also called a probability distribution, assigns the probability P(X = r) for
any possible value r of a discrete random variable X, for the r values with positive probability.
If a random variable has a large number of values with positive probabilities, then measures of
location and spread can be calculated to better summarize the random variable, as in samples.
Expected Value
The mean of a random variable is called the expected value E(X), or the population mean (µ). It is
calculated as:
R
E ( X ) ≡ µ=∑ xi P ( X=x i ) ,where x i are all the possible values of X with a positive probability .
i=1
This can be thought of as a weighted average of possible values, where the weights are the
theoretical probability for each value. As long as the individual values are distinct from each other, or
they are discrete, R can be finite or infinite.
Population Variance
Variance of a random variable Var(X) is called the population variance σ2. It can be calculated as:
R
Var ( X ) ≡σ 2=∑ ( x i−µ ) P ( X=x i ) ,∨¿ Var ( X ) ≡σ 2=E ( X 2 ) −( E ( X ) )
2 2
i=1
R
¿ E ( X −µ ) =∑ x 2i P ( X =xi ) −µ2
2
i=1
where x i are all the possible values of X with a positive probability .
Analogous to the sample standard deviation, the standard deviation of a random variable sd(X) or σ
is:
√ Var (x)
Approximately 95% of the probability mass is represented within two standard deviation (2σ) range
of the mean of a random variable.
Cumulative-distribution function (cdf) of a random variable X, F(X), assigns each possible value of X,
the sum of probabilities of all the values that are no larger than the considered value. So, for a
specific value x of a random variable X, it is defined as:
k
P ( X ≤ x k ) =∑ P ( X =xi )
i=1
Bernoulli Distribution
The simplest of the discrete probability distributions.
Result of a single coin toss: P(X = heads) = 0.5, P(X = tails) = 0.5, result of a normal coin toss is
either heads or tails with a 0.5 probability for each.
GC content of a DNA molecule: P(X = AT) = 0.6, P(X = GC) = 0.4, the GC content of human genome is
approximately 50%.
Binomial Distribution
Multiple Bernoulli Trials:
If we choose 5 consecutive bases in a DNA molecule, what is the chance that it will be:
GACGT
CTGCA
Bernoulli trials are mutually independent. Thus, we can calculate this probability by multiplication
rule.
P(DNA = GACGT) = P(B1 = GC) * P(B2 = AT) * P(B3 = GC) * P(B4 = GC) * P(B5 = AT)
P(DNA = GACGT) = p * q * p * p * q
P(DNA = GACGT) = p3 * q2
P(DNA = GACGT) = 0.43 * 0.62
P(DNA = GACGT) = 0.023
Multinomial Distribution
Let’s keep following the GC content examples for the Bernoulli and Binomial distributions.
+…+ p y =1
∏ ki !
i=1 1 2 3 y 1 2 3
i=1
Poisson Distribution
Poisson distribution is related to rare events.
There are three assumptions for Poisson distribution, where t is a long period of time and Δt is a
small sub interval of t:
1- Assume that
P(1 event) = λΔt for some constant λ.
P(0 event) ≈ 1 – λΔt
P(>1 event) = 0
2- Stationarity the number of events occurring in a unit time does not change over t. This
assumption is less likely to hold for overly long periods of t.
3- Independence if an event occurs in a Δt, it has no effect on the probability of occurrence of
another event in the next Δt.
Then, the probability of k events occurring in a time period of t for a Poisson random variable with
parameter λ is:
−µ k
( ) e µ
P X=k = , k=0 , 1 , 2, …where µ=λt ∧e 2.71828
k!
Poisson distribution depends on a single parameter µ = λt. Where λ represents the expected number
of events per unit time, and µ represents the expected number of events over time period t.
In Binomial distribution, there are a definite number of trials, n, and the number of events can be no
larger than n.
However, in Poisson distribution, the number of trials is infinite, and the number of events can be
indefinitely large. The probability of k events becomes very small as k increases.
E(X) ≈ Var(X) for a Poisson distribution. Since it is often hard to predict whether the assumptions for
the Poisson distribution are satisfied, this feature can help to preliminarily identify a distribution as
Poisson before using other tests to confirm this hypothesis.
Since the expected value E(X) of a Poisson distribution is µ, the parameter µ can be estimated from
the observed mean number of events over time t. If the data are not available, other sources can be
used to estimate µ.
For a Binomial distribution, the expected value and the variance are given as np and npq respectively.
In the case of a Poisson distribution with parameters as a large n (≥ 100) and a small p (≤ 0.01),
In this case, this Binomial distribution can be accurately approximated by a Poisson distribution with
parameter µ = np.
This is useful because Poisson distribution is easier to work with then Binomial distribution.
Week 6
Negative Binomial Distribution
In Binomial distribution, the probability in question was:
What is the probability of k successes in n independent trials, with a probability of p for success?
In other words, the number of trials, n, is fixed in Binomial distribution, while the number of
successes, k, is fixed in the Negative Binomial distribution.
For n trials, the probability of k – 1 success in n – 1 trials is calculated, and then multiplied by the
probability of a success.
Geometric Distribution
Geometric distribution is a special case of Negative Binomial distribution, where k = 1.
That means, we want the probability of getting the first success after n independent trials, where
the probability for each success is p.
Then we have:
( n−1 )
P ( X=n )=q p , where
p=the probability of a success , q=1− p ,∧n=the number of trials until the first success
E(X) of Geometric distribution is 1/p
Note: When there is replacement in the trials, then the conditions turn into conditional probabilities,
where each trial has a probability of success p, which is affected by the outcome of last trial.
If there are 3 blue and 2 red balls in a bag, what is the probability of getting a blue ball?
This is simply is 3/5.
Given that the first ball was blue, what is the probability of getting another blue without replacing the
first one?
If the blue ball is not replaced, then there are 2 blue and 2 red balls in the bag.
The probability of getting a blue in the second trial becomes 2/4 = 1/2
That means, the trials are not independent, so we cannot simply use Binomial distribution to model
this sampling.
If we have 3 blue and 2 red balls in a bag, what is the probability of picking 2 blue balls in 3 picks?
At the last step we summed each combination of 2 blue and 1 red balls:
3 3 2
∗2 ∗2 ∗3
5 5 5
∗2 ∗2 ∗2
4 4 4
+ +
3 3 3
3∗3
∗2
5
∗2
4
¿ , follow the ¿ ¿
3
3!
∗3!
2!
∗2 !
1!
∗2 !
1!
¿
5!
3!
∗2 !
1!∗2 !
∗2!∗3 !
1!
¿
5!
3!
∗2 !
2!∗1 !
1 ! 1!
¿
5!
2 !∗3 !
3 C 2∗2 C 1
¿
5 C3
Thus, we can easily calculate the probability of getting 2 blue balls in 3 trials with no replacement,
from a pool of 3 blue and 2 red balls as combination of 2 blue balls out of all three, multiplied by
combination of 1 red ball out of 2, all divided by combinations of 3 balls out of all 5.
m Ck ∗N −m C s− k
P ( X=k )= , fork =max ( 0 , s +m−N ) , … , min(m, s )
NCs
m
E(X) of Hyper Geometric distribution is s
N
If the sampled fraction of the population, s, is no more than 5% of the main population, N; picking
items from the population without replacement will change the probabilities so slightly. That means,
the probability for success at each independent trial will remain somewhat constant, and the Hyper
Geometric distribution will behave like Binomial distribution.
In this case Hyper Geometric distribution can be approximated by the Binomial distribution.
The idea is the same as in Hyper Geometric distribution. We just multiply all miCki for each different
choice, and then divide the result by combinations of total of kis in whole population, NCs.
y
∏ mi C k i
m1 +m2+ …+mi=N , total population
P ( X =k 1 , k 2 ,… , k y )= i=1 , for
Cs N
k 1+ k 2+ …+k i=s , numebr of sample /trials
Week 7
Continuous Probability Distributions
In a continuous range, such as [a, b], there are infinitely many values.
Thus, unlike a discrete random variable, a continuous random variable is not countable; and the
probability of picking a single specific value from a continuous range is practically 0 (1/infinity).
However, the probability of a value falling in sub-range of the continuous range [a, b] can be
calculated.
Then the bus can arrive at any minute interval in the next 6 minutes. Thus, the bus follows a
continuous uniform distribution.
P(X = x) = p, x = [0, 6]
The probability of the bus arriving in a given time interval can be calculated as the area under the
curve in that time interval.
But the probability that the bus will arrive at a specific time, say 1 minutes 45 seconds and 84
milliseconds later, is 0.
The area under the probability density function of a random variable X, between any two points a
and b, gives the probability that the value of X falls between a and b.
The cumulative distribution function for a random variable X is evaluated at point a, and gives the
probability that the value of X is smaller than or equal to a. Thus, it is calculated as the area to the left
of a, under the pdf function.
P(X ≤ a) = P(X < a) because P(X = a) = 0
Expected value, E(X) or µ, of a random variable X is the average value that is taken on by X
Variance, Var(X) or σ2, of a random variable X is the average squared distance of each value of X from
the E(X), which is given by E(X - µ)2 or E(X2) - µ2.
The standard deviation, σ, of a random variable X is the square root of its variance, that is:
σ =√ Var (X ).
Normal Distribution
The normal distribution is the most widely used continuous probability distribution in statistics.
1
e
[ −1
2σ
2
( x−µ )
2
], ∞
−¿< x<∞
+ ¿,¿
¿
for parameters µ∧σ , where σ >0.
√2 π σ 2
The probability density function for a normal distribution follows a bell-shaped curve.
The peak of the curve, in other words the mode of the distribution, is at µ, and the most frequently
occurring values around µ.
The curve is symmetrical about µ with points of inflection, meaning the points at which
the slope of the curve changes direction, on either side of µ at µ - σ and µ + σ.
µ and σ2 are used to define a normal distribution, because µ and σ 2 are expected
value, and variance and the variance of a normal distribution, respectively.
The entire shape of the curve is also determined by µ and σ 2.
A special case of anormal distribution is when µ = 0 and σ 2 = 1, N(0, 1). A normal
distribution of this form is called the standard normal distribution.
Substituting µ and σ2 for 0 and 1 respectively, in the probability density function
for a normal distribution:
1
e
−
[ ( ) ],∞
1
2σ2
( x−µ )
2
−¿<x <∞
+¿ ,¿
¿
√2 π σ 2
2
let µ=0∧σ =1 , then:
−1 2
1 x +¿ ¿
e 2
, ∞−¿<x <∞ ¿
√2 π
The standard normal distribution is symmetrical about 0, because f(x) = f(-x).
about 68% of the area under the curve is in between -1 and +1,
about 95% of the area under the curve is in between -2 and +2, and
about 99% of the area under the curve is in between -3 and +3.
The area under the cdf curve to the left of -x is equal to the area under the cdf curve to the
right of the x. Or,
The probability that X is smaller than or equal to -x is equal to the probability that X is greater
than or equal to x.
So, knowing the probabilities for only 1 side of the distribution, i.e. X < µ or X > µ, is enough.
One possible way to define a normal range for some values, say the normal birth weight for
newborns, is to use arrange within x standard deviations for some specified value of x.
Another way is to use percentiles of the distribution, for example upper and lower 5th percentiles.
th
The ( 100∗u ) percentile of a standard normal distributionis denoted by z u
P ( Z < z u ) =u , where Z N (0 ,1)
zu is sometimes referred to as the invers normal function. This is because we first find the area u in
the table, to then find the corresponding value zu.
Note: If u < 0.5, we have to use symmetry properties of the normal distribution to obtain zu = -z(1-u)
Actually, it is possible to describe the pth percentile of a general normal distribution (x) as the
percentiles of the standard normal distribution:
x=µ+ z p σ
Note: this is only applicable if random variable X follows the normal distribution, in other words if
random variable X satisfies the assumption of normality. This means, the conversion only scales the
distribution.
By scaling a normal distribution to standard normal distribution, we can employ powerful statistical
tests that are only applicable to standard normal distributions.
X−µ
if X N ( µ , σ ) ,∧Z=
2
,then Z N ( 0 , 1 ) ,∧¿
σ
P ( a ≤ X ≤b )=P (
a−µ
σ
<Z<
b−µ
σ
=φ ) ( ) ( )
b−µ
σ
−φ
a−µ
σ
The idea is, if the random variable X follows a random distribution N(µ, σ2), then:
We can first subtract the mean from the X to bring the center of the distribution to 0:
o X–µ
Then, we can divide this value by σ to scale the spread, so that points of inflection are at µ – 1
and µ + 1, or σ = σ2 = 1:
o (X – µ) / σ
This example was skipped during the class but worth knowing about:
Linear Combinations of Random Variables
This concept is also known as Linear Contrast, Linear Transformation, and Linear Mapping.
Often, we need to compute expected value, and the variance for the linear combinations.
Expected Value:
Variance:
Any linear combination of independent normal random variables will also follow a normal
distribution.
if X 1 , X 2 , … , X n are independent normal random variabiles
2 2 2
with expected values µ 1 , µ 2 , … , µn∧variances σ 1 , σ 2 , … , σ n ,
n
¿ Lis any linear combination=∑ c i X i ,Then Lis normally distributed with:
i=1
n n
Expected value , E ( L )=∑ c i µi ,∧¿Variance , Var ( L )=∑ c 2 σ 2i
i=1 i=1
Week 8
Midterm
Week 9
Sampling
A random sample is a selection of members of a population, where each member has an
independent non-zero probability of being selected.
A simple random sample is a random sample where each member has the same probability of being
selected.
The group under study, or the group where the sample is selected from, is called; reference, target
or study population.
A random number, or a random digit, is a random variable X that takes on the values 0, 1, 2, …, 9
with equal probability:
1
P ( X=0 )=P ( X =1 )=P ( X=2 )=…=P ( X=9 )=
10
Computer-generated random numbers are collection of digits that satisfy:
These are also called pseudo random numbers because they satisfy these conditions approximately.
Random selection is when a sample is chosen randomly to represent the population. Data from
random selection can be used for generalization.
Random assignment is when the sample is randomly assigned to groups (i.e., treatment/control).
Data from random assignment can be used for causality.
A Randomized Clinical Trial (RCT) is a type of research design to compare different treatments.
Randomization is the process where the patients are randomly assigned to a specific treatment. If
the samples are large enough, the treatment groups will include similar types of patients. If the
samples are small, the treatment groups may not be comparable. A table of characteristics can be
presented for each treatment group to check if randomization worked well in RCTs.
Block randomization is a process where a block size, of kn, is predetermined for k treatment groups;
and for each kn patients entering the study, n patients are randomly assigned to 1st treatment, n
patients are randomly assigned to 2nd treatment, …, and n patients are randomly assigned to kth
treatment. This is the other way to refer to random assignment.
For every kn patients, there will be equal number of patients assigned to in each group, and the sizes
of treatment groups will be equal throughout the study period. This ensures comparability of
treatment groups over short periods of time as the study procedures change and are adjusted.
The randomization process may get apparent over time and physicians may take decisions that will
affect the randomization (i.e., prioritizing certain patients, delaying their entry to study until a
treatment gets more likely to work). To avoid this, variable block size is sometimes preferred.
In stratification, patients are divided into groups, or strata, based on characteristics that could be
important for the outcome of trials; such as age, gender, or over all clinical condition. Then, random
selection or random assignment can be used in each stratum. Separate randomization lists are
maintained for each stratum to ensure comparable patient populations in each stratum.
Blinding:
If neither the patients nor the physicians know which treatment is applied to which group,
this is called a double-blind study.
If only patients don’t know what treatment they get, but the physicians are aware of the
study plan, this is called a single-blind study.
Degrees of freedom, is the number of parameters that can be freely decided on, until an
underdetermined system becomes determined.
Here, for example y and z are free parameters. The value of x depends on y and z. The equation can
be rearranged for y or z too. So, the number of free parameters = the degree of freedom = 2.
In general:
3–2=1
3–1=2
This time we have sample mean and sample
variance equations as a system.
Estimation – I (Mean)
How is a specific random sample x1, x2, …, xn, of a population can be used to estimate the µ σ2 of the
underlying distribution.
Inferring the properties of a distribution underlying the data at hand involves inductive reasoning
(tüme varım), rather than deductive reasoning (tümden gelim).
Estimation: Estimating the values of specific population parameters (mean, variance, etc.).
Hypothesis Testing: Testing if the value of a population parameter is equal to some specific
value.
When a specific value is estimated for a parameter, this is called point estimate.
When a range of values within which the values of a parameter are likely to fall, this is called
interval estimate. If this range is narrow, then the point estimate can be considered good.
Point Estimation
A natural estimator for the estimation of population mean µ is the sample mean.
n
Xi
X =∑
i=1 n
Sampling distribution of X , is the distribution of values of x over all possible samples of size n, that
could have been selected from the reference population.
More generally:
The larger the sample size, the more precise the estimator X is.
Let X1, X2, …, Xn be a random sample from a population with mean µ and variance σ2.
( )
n n
1
Var ( X )= 2 ∗Var
n
∑ X i Var ( X )= n12 ∗∑ Var ( X i ) ,∧Var ( X i ) =σ 2
i=1 i =1
√
2 2
1 nσ σ σ2 σ
Thus , Var ( X )= 2
∗( σ
2
+σ
2
+…+ σ
2
) Var ( X ) = 2
= ,∧¿ SD=√ Var ( X )= =
n n n n √n
The set of sample means in repeated random samples of size n from this population has variance
σ /n. The standard deviation of this set of sample means is σ /√ n and is called the standard error of
2
However, often times, the population variance σ2 is unknown. Thus, sem is estimated by s/ √ n.
Shortly, standard error of the mean, represents the estimated standard deviation of a set of sample
means, which are obtained by repeated random samples of size n from a population with variance
σ2.
Thus, the greater the sample size n, or the smaller the population variance σ2; the lower the
standard error of the mean, and the more precise the estimate of µ.
If the population is distributed normally, then X also follows a normal distribution with mean µ
and variance σ 2 /n:
2
X N ( μ , σ / n)
Moreover, even when the underlying distribution is not normal, for a large sample size n, X
approximately follows a normal distribution with mean µ and variance σ 2 /n:
Interval Estimation
Often times, along with a precise point estimate, we also want an interval of acceptable values for
the parameter being estimated. This is interval estimation. According to central-limit theorem,
interval estimates hold exactly if the population is distributed normally and approximately if the
population is not distributed normally.
If X N ( μ , σ 2 / n), and if we knew µ and σ2, then we could precisely know the behavior of the set of
sample means over a large number of samples of size n. More precisely:
We already discussed that, when σ is unknown, the standard error of the mean σ /√ n can be
estimated using sample variance by s/ √ n.
However, we cannot use the above property with s/ √ n, because (X −μ)/(s/ √ n) does not follow a
normal distribution anymore.
(X −μ)/(s/ √ n) is referred to as Student’s t distribution, and the shape of the distribution depends
on the sample size n. t distribution is a family of distributions indexed by the degrees of freedom
(df) of the distribution.
If X1, …, Xn ~ N(µ, σ2) and are independent, then (X −μ)/(s/ √ n)is distributed as t distribution with
(n-1) df.
The 100 x uth percentile of a t distribution with d degrees of freedom is denoted by td, u and given as:
P ( t d <t d , u ) ≡ u
As d becomes large, the corresponding t distribution, td, converges to an N(0, 1) distribution. This is
because d = (n-1) and for larger sample size n s2 approximates better to σ2.
The difference between t distribution and the standard normal distribution is the greatest for n < 30.
t=( X −μ ) /(s /√ n)
This quantity should follow a t distribution with (n-1) degrees of freedom, t(n-1).
95% of the statistic in repeated samples of size n should fall between 2.5th and 97.5th percentiles of a
t(n-1) distribution, shortly:
This can also be generalized as, 100% x (1-α) of the t statistics should fall between lower and upper
α/2 percentiles of the t(n-1) distribution in repeated samples of size n, shortly:
P t
( n−1,
α
2
< t<t
n−1 ,1−
α
2
)=1−α
The inequality can be divided into two inequalities:
X −μ
∧X−μ
s /√ n
t α < <t α
n−1 ,
2
s /√ n n−1 ,1−
2
Then, multiply each side by (s/ √ n) and add µ to each side, to obtain:
t
n−1 ,
α
2
( √sn )+ μ< X ∧X <t n−1 ,1−
α
2
( √sn )+ μ
Finally, subtract t
n−1 ,
α
2
( √sn ) from both sides in the first inequality, and t
n−1 ,1−
α
2
( √sn ) from both sides
μ< X−t
n−1 ,
α
2
( √sn )∧X −t n−1, 1−
α
2
( √sn )< μ
Expressed as a single inequality, as in the beginning, we obtain:
X −t
n−1 , 1−
α
2
( √sn )< μ< X−t ( √sn ) n−1 ,
α
2
The t distribution is also symmetrical, such that tn-1, α/2 = -t n-1, 1-α/2. So, the inequality can be written as:
X −t
n−1 , 1−
α
2
( √sn )< μ< X +t n−1 ,1−
α
2
( √sn )
Thus, it can be said that:
P X−t
( n−1 ,1−
α
2
( √sn )< μ< X +t n−1 ,1−
α
2
( √sn ))=1−α
(
The interval X−t
n−1 ,1−
α
2
( √sn ), X + t n−1 ,1−
α
2
( √sn )) is referred to as the 100% * (1 – α) confidence
interval (CI) for the mean µ of a normal distribution with unknown variance.
X ±t
n−1 , 1−
α
2
( √sn )
The boundaries of the interval depend on the sample mean and sample variance, and vary from one
sample to another. For A% CI for the µ of a normal distribution with unknown variance, A% of such
intervals that could be constructed from repeated random samples of size n, will contain population
parameter µ.
Moreover, the length of the CI gives some idea about the precision of the point estimate x , and is
given by:
2∗t
n−1 ,1−
α
2
( √sn )
From this, we understand that the length of a CI is determined by 3 variables:
n: as the sample size n increases, the length of the CI decreases.
s: as the sample standard deviation s increases the length of the CI increases.
α: as the alpha decreases, the desired confidence increase (1- α), and the length of the CI
increases.
If the sample size is sufficiently large, x > 200, then the distribution converges to a normal distribution
and their percentiles are virtually the same. In this case 100% * (1 – α) CI for µ of a normal
distribution with unknown variance can be approximated as:
X±z
1−
α
2
( √sn )
This interval can also be used if the variance is known, by replacing s with σ.
Week 10
Hypothesis Testing – I (Mean)
Hypothesis testing enables us to make decisions based on a consistent uniform criterion.
In other words, alternative hypothesis is the extreme condition that we investigate, and the null
hypothesis is the opposite of alternative hypothesis which we expect to observe in the population
already.
For example, if we think that the mean of a group is smaller than the other, our null and alternative
hypotheses can be expressed shortly as:
H 0 : μ=μ 0 vs . H 1 : μ< μ 0
Practically it is impossible to use statistical testing methods and prove that the null hypothesis is
true. Thus, if we accept H0, then we say we failed to reject H0.
Note: Why it is impossible to prove null hypothesis?
Because we assume the samples are coming from some distributions, and we cannot really now the
true distributions with exact parameters. Thus, we can only claim that there is not enough data to
reject H0, or show it is false. Hence, we fail to reject H0.
Imagine that someone committed a crime, but we don’t know about it. This person is suspected to be
guilty, and we try to prove this is true. In this case:
So, if we gather enough evidence, we can reject H0, and say accused is actually guilty.
However, if we can’t gather enough data, that does not prove accused is innocent. We just fail to
falsify that accused is innocent.
Therefore, since we do not now the true nature of the underlying distribution, there is always a small
chance that H0 is not true, and thus we can’t prove H0 is true, but we can only fail to reject H0.
Correct decision:
Type I error:
H0 is true, and H0 is rejected.
P ( reject H 0∨H 0 istrue )=P ( type I error ) =α =significance of the test
Type II error:
H1 is true, and H0 is accepted.
P ( type II error )=β ,∧¿1−P ( accept H 0∨H 1 is true )=1−P ( type II error )
¿ 1−β= power of the test=P ( reject H 0∨H 1 istrue )
We aim to make α and β as small as possible for the statistical tests. However, making α small means
rejecting H0 less often, and making β small means accepting H0 less often. Moreover, as α decreases,
β increases, and vice versa. A general strategy is to fix α at some specific level and to use the test
that minimizes β, thus maximizing the power (1 – β).
ONE-SAMPLE TEST FOR THE MEAN OF A NORMAL DISTRBUTION: ONE SIDED ALTERNATIVES
Say we want to test if a sample has lower mean than a population, assuming they both follow a
normal distribution with mean µ and an unknown variance σ2.
The best, or most powerful test would be based on the sample mean x , which has the highest
power (1 – β) for a fixed significance (α).
That makes sense because if H0 is true, then the most likely values of x tend to cluster around µ0,
whereas if H1 is true then the most likely values of x tend to cluster around µ1.
The acceptance region: is the range of values of x for which we fail to reject H0.
The rejection region: is the range of values of x for which we reject H0.
One-tailed test: the values of the parameter being studied (in this case µ) under H1, are allowed be
either smaller than or greater than the values of the parameter under H 0, but not both.
Suppose H0 is rejected for all values of x < c, and accepted otherwise. The value c should be selected
so that the probability of type I error = α.
If we define the criteria based on the standardized terms, instead of x , for convenience:
X−μ 0
S t= t n −1
if we subract μ0∧divide by , we get s
√n
√n
¿ the definition of the percentilesof a t distribution: P ( t< t n−1 , α ) =α
So, we will calculate t values, and reject H0 for t < tn-1, α, and accept it otherwise.
The t value here is called a test statistic because the test procedure is based on this statistic.
tn-1, α here is called the critical value. The outcome of the test depends on the relation of test statistic
and the critical value. In this case, for example, we reject H0 if test statistic < critical value, t < tn-1, α.
This general approach, where a test statistic is calculated and compared to a critical value,
determined by the significance of the test (α, probability of type I error), to decide on the outcome
of the test is called the critical-value method of hypothesis testing.
Procedure: One – Sample t Test for The Mean of A Normal Distribution with Unknown Variance,
One – Sided (Alternative Mean < Null Mean)
To test the hypothesis H 0 : μ=μ 0 , σ unknown vs . H 1 :μ < μ0 , σ unknown with a significance level of
α, we compute:
X−μ 0
t=
S
√n
If t <t n −1 , α , then we reject H0.
The level of significance, α, depends on the relative importance of type I and type II errors. This is
because, for a fixed sample size (n), as α gets smaller, β gets greater and the power of the test (1 – β)
drops.
Generally, significance levels greater than 0.05 are not welcomed, and α = 0.05 is used most
frequently.
Several statistical tests at different α levels can be performed and whether H0 would be rejected or
accepted could be noted. A lot of work, and unnecessary.
Significance tests can be effectively performed at all α levels, by calculating the p-value for the test.
p-value for any hypothesis test is the α level at the borderline of acceptance and rejection regions.
In other words, we would neither accept not reject H0 at the α level of p-value.
reject H 0 for t <t n−1, p ,accept H 0 for t >t n−1 , p ,no choice for t=t n−1 , p
However, if 0.05 < p < 0.1, the trend towards statistical significance is sometimes noted.
If, instead of the critical value method, p-value for the test is calculated, it is referred to as the p-
value method. If p < 0.05, H0 is rejected and the results are declared statistically significant.
Otherwise, the H0 is accepted and the results are declared to be NS.
Sometimes, the results of a study may be statistically significant but scientifically not important.
This may occur if slight differences found to be statistically significant because the sample size is
large.
In contrast, some results may not be statistically significant but can be scientifically important. This
may encourage researchers to perform larger studies to confirm the results, and possibly reject H0
with a larger sample size.
Procedure: One – Sample t Test for The Mean of A Normal Distribution with Unknown Variance,
One – Sided (Alternative Mean > Null Mean)
To test the hypothesis H 0 : μ=μ 0 , σ unknown vs . H 1 :μ > μ0 , σ unknown with a significance level of
α, we compute:
X−μ 0
t=
S
√n
If t >t n −1 , 1−α, then we reject H0.
In a two-tailed test, the values of the parameter being studied (in this case µ) under H1 are allowed
be on both sides of (either greater or less than) the values of the parameter under H0 (µ0).
In a two-tailed test, we will reject H0 if the alternative values of the parameter on two sides of the
null are too small or too large.
In other words, H0 will be rejected either for t > c1 or t < c2 for some constants c1, c2 and H0 will be
accepted if c1 ≤ t ≤ c2.
α
P ( t< c 1∨H 0 is true ) =P ( t> c 2∨H 0 is true ) =
2
Since t follows a tn-1 distribution under H0, tn-1, α/2 and tn-1, 1 – (α/2) are the lower and upper 100 x (α/2)
percentiles of a tn-1 distribution. So:
α
(
P t< t
n−1 ,
α
2 ) (
=P t>t
n−1 ,1−
α
2 )
=
2
Therefore:
To test the hypothesis H 0 : μ=μ 0 vs . H 1 : μ ≠ μ 0, with a significance level of α, the best test is based
on:
X−μ 0
t=
S
√n
If |t |>t n−1 ,1− α , then we reject H0.
2
The p-value for the one-sample t test for the mean of a normal distribution, two-sided:
X−μ 0
Let t=
S p=
√n
{
2∗P ( t n −1 <t ) , if t ≤ 0
2∗[ 1−P ( t n−1< t ) ] , if t >0
If sample size is large enough (n > 200, but Dr. Pir says even > 30 is enough), then the t distribution
( t>t ) used in determining the critical values can be approximated by the percentiles of N(0,1)
n−1 ,1−
α
2
distribution ( z ). Similarly, I computing p-values, p = P(t < t) can be approximated by P[N(0, 1) <
1−
α n-1
2
t] = φ(t).
ONE-SAMPLE z Test
In some cases, the variance may be assumed to be known from previous studies. In this case the test
statistic t can be replaced by z=(X−μ 0)/(σ / √ n). Also, the critical values that were based on the t
distribution can be replaced by the corresponding critical values from the z distribution. This leads
to the following procedure.
Procedure: One – Sample z Test for The Mean of A Normal Distribution with Known Variance, One –
Sided (µ1 < µ0)
To test the hypothesis H 0 : μ=μ 0 vs . H 1 : μ< μ 0 with a significance level of α, where the underlying
standard deviation σ is known, the best test is based on:
X−μ 0
z=
σ
√n
If z < z α , then we reject H0.
p=ϕ (z)
Procedure: One – Sample z Test for The Mean of A Normal Distribution with Known Variance, One –
Sided (µ1 > µ0)
To test the hypothesis H 0 : μ=μ 0 vs . H 1 : μ> μ 0 with a significance level of α, where the underlying
standard deviation σ is known, the best test is based on:
X−μ 0
z=
σ
√n
If z > z 1−α, then we reject H0.
p=1−ϕ (z )
Procedure: One – Sample z Test for The Mean of A Normal Distribution with Known Variance, Two –
Sided
To test the hypothesis H 0 : μ=μ 0 vs . H 1 : μ ≠ μ 0, with a significance level of α, the best test is based
on:
X−μ 0
z=
σ
√n
p=
{ 2∗ϕ ( z ) , if z ≤ 0
2∗[ 1−ϕ ( z ) ] , if z >0
t α ∗s
n −1 , 1−
The two-sided 100% x (1 – α) CI for µ = (c1, c2) = x ± 2 .
√n
Suppose we reject H0 at level α. That means either t <−t n−1 , 1− α or t >t n −1 , 1− α .
2 2
Suppose that:
t α ∗s
n−1 , 1−
2
x−μ0 ←
√n
Add μ0 to both sides:
t α ∗s
n−1 ,1−
2
x < μ0−
√n
or
t α ∗s
n−1 ,1−
2
μ0 > x + =c 2
√n
Similarly, for α:
t >t
n −1 , 1−
2
t α ∗s
n−1 ,1−
2
x−μ0 >
√n
or
t α ∗s
n−1 ,1−
2
μ0 < x− =c 1
√n
This means that, if we reject H0 at level α using a two-sided test, then either µ0 <
c1 or µ0 > c2; That is, µ0 must fall outside of the two-sided 100% x (1 – α) CI for µ.
It can also be shown, similarly, that if we accept H0 at level α using a two-sided test, then µ0
must fall within the two-sided 100% x (1 – α) CI for µ (or c1 < µ0 < c2).
The p-value from a hypothesis test tells us how statistically significant the
results are.
However, the significant results may not be scientifically important because the
difference between means are not so great and the significance is due to large
sample size.
The power is calculated to plan a study before any data have been obtained.
A small preliminary study, called a pilot study, can be performed to asses the
variables required to calculate power.
Thus, the standard deviation is assumed to be known and the power calculations
are based on one-sample z tests.
we accept H 0 if z > z α
So far, we have seen that for testing, let’s say, H 0 : μ=μ 0 vs . H 1 : μ ≠ μ 0, the form of
the best test does not depend on the specific value of alternative mean, as long
as this value is less than the null mean.
However, the specific value of alternative mean affects the power of the test,
which is:
1 – P(type II error).
Power=1−P ( type II error )=1−P(accept H 0∨H 0 is false)
( | )
x−μ0
¿P < z α μ=μ1
σ
√n
(
¿ P X < μ0 +
z α ∗σ
√n | )
μ=μ1
[(
Power=ϕ μ 0+
z α∗σ
√n ) ] [
−μ1 /(σ / √ n) =ϕ z α +
μ0−μ1
σ
∗√n ]
Which is the area to the left of z α + ∗√ n under N(0, 1) distribution.
μ0 −μ1
σ
The area to the left of μ0 + under the H0 distribution is the significance level
z α∗σ
√n
= α, whereas the area to the left of μ0 + under the H1 distribution is the
z α∗σ
√n
power = 1 – β.
With a similar reasoning to previous one, the power of this test would be:
[
Power=ϕ −z 1−α +
μ1−μ 0
σ ] [
∗√n = ϕ z α +
μ 1−μ0
σ ]
∗√ n , if μ1 > μ0
H 0 : μ=μ 0 vs . H 1 : μ< μ 0
Where the underlying distribution is normal and the population variance (σ2) is
assumed to known is given by:
[
Power=ϕ −z 1−α +
|μ0 −μ1|
σ ] [
∗√ n =ϕ z α +
|μ0 −μ 1|
σ
∗√ n ]
The power depends on 4 factors:
1- If α decreases, zα decreases, and hence the power decreases.
2- If |µ0 – µ1| increases, the power increases.
3- If sigma increases σ, the power decreases.
4- If n increases, the power increases.
Power=ϕ −z
[ 1−
α
2
+
( μ0−μ 1 )
σ
∗√ n +ϕ −z
] [ 1−
α
2
+
( μ1−μ 0 )
σ
∗√ n
]
And approximated by:
Power=ϕ −z
[ 1−
α
2
+
|μ0 −μ 1|
σ
∗√ n
]
If µ1 < µ0, the second term of the equation is negligible compared to the first one, and usually only the
first term used as an approximation.
If µ0 < µ1, the first term of the equation is negligible compared to the second one, and usually only the
second term used as an approximation.
Sample Size Determination
If the required sample size is too big, knowing this before starting the study will save us a lot of effort
and resources, and we can replan our study to make it more practically possible.
For one-sided
The sample size that is needed to be able to detect a significant difference with probability 1 – β,
given that a one-sided statistical test will be performed at significance level α, and that the true
alternative mean is µ1.
[
Power=ϕ z α +
|μ 0−μ1|
σ
∗√ n =1−β]
We want to solve for n in terms of α , β ,|μ0−μ1|,∧σ .
|μ 0−μ1|
zα+ ∗√ n=z1− β
σ
Subtract z α from each side:
|μ0 −μ1|
∗√ n=z 1− β−z α
σ
σ
Multiply each side by :
|μ0 −μ1|
z 1−β −z α
√ n= ∗σ
|μ0 −μ 1|
From properties of percentiles of z distribution, we know z 1−α =−z α . Therefore:
z 1−β + z1−α
√ n= ∗σ
|μ 0−μ1|
Finally, square both sides to get n, and thus the sample size required to perform a one-sided
hypothesis test at significance level α and detect a statistically significant difference with a
probability of 1 – β is obtained as:
2
( z 1− β + z 1−α ) 2
n= 2
∗σ
( μ0−μ1 )
The sample size is always rounded up, to make sure we achieve at least the required level of power.
size is 4 times as large. If, on the other hand, |μ0 −μ1| is doubled, then the required sample size is 4
times as small.
For two-sided:
The sample size required to perform a two-sided hypothesis test at significance level α and detect a
statistically significant difference with a probability of 1 – β is obtained as:
( ) ∗σ
2
z1− β +z α
1−
2 2
n= 2
( μ0−μ1 )
This sample size is always larger than the one-sided alternative because z 1−α < z1− α .
2
Sometimes it is already known that there will be a significant result (i.e. physiological effect of a
drug). The interest is focused on estimating this result with a given degree precision.
Suppose we quantify the precision of the estimation by the width of the two-sided 100% * (1 – α) CI.
( )
t α ∗s
n−1 , 1−
2
2∗
√n
We eish this interval to be no wider than a constant L:
( )
t α ∗s
n−1 , 1−
2
2∗ =L
√n
( )
t α ∗s
n−1 ,1−
√ n=2∗ 2
L
( )
2
t α ∗s
n−1 ,1−
n=22∗ 2
L
2 2
4∗t α ∗s
n−1, 1−
2
n= 2
L
2 2
4∗z α ∗s
1−
2
n= 2
L
Thus, the sample size n for the estimation of the mean of a normal distribution with sample variance
s2, and with a two-sided 100% * (1 – α) CI for µ no wider than L is calculated.
Estimation II (Variance)
Estimation of The Variance of A Distribution
Point estimation
Let X1, X2, …, Xn be a random sample from some population with mean µ and variance σ2. The sample
variance S2 is an unbiased estimator of σ2 over all possible random samples of size n that could have
been drawn from that population.
E ( S2 ) =σ 2
This estimation holds for any underlying distribution.
Remember:
n
1
s=2
∑
n−1 i=1
( x i−x )
2
i=1
and the Xi’s are independent, then G is said to follow a chi-square distribution with n degrees of
2
freedom. The distribution is often noted by χ n .
Like t distribution, chi-square distribution is also a family of distribution indexed by the parameter n
referred to as degrees of freedom (df).
However, unlike the t distribution, chi-square distribution only takes on positive values and always
skewed to the right.
The interval estimates will hold exactly, only if the underlying distribution is normal, as in the interval
estimates of the mean. However, they perform poorly if the underlying distribution is not normal, in
the case of variance. Thus, they should be used with caution.
2
Assume that X 1 , X 2 , … , X n N ( µ , σ ).
X−μ
If X N (µ , σ 2 ), and Z= , then Z N ( 0 , 1 ). Thus:
σ
2
n n
( x i−μ )
∑ Z =∑ 2
i
σ 2
χ 2n
i=1 i=1
We usually don’t know μ and estimate it by x . However, if we substitute x for μ, we lose one 1 df
resulting in:
2
n
( x i−x )
∑ σ 2
χ 2n−1
i=1
i=1
( )
2 2
σ 2 2 σ 2
P ∗χ α < S < ∗χ =1−α
( n−1 ) n−1 ,
2 ( n−1 ) n−1 ,1− α2
( n−1 )∗S 2
∧( n−1 )∗S2
χ2 α
n−1 ,
σ 2< 2
2
< σ2
χ α
n−1 , 1−
2
[ ]
2 2
( n−1 )∗S 2 ( n−1 ) ∗S
P 2
<σ < 2 =1−α
χ α χ α
n−1 , 1− n−1 ,
2 2
( n−1 )∗s 2 2
2
X = χ n−1
σ2
Therefore,
α
( ) ( )
2 2 2 2
P X <χ α = =P X > χ α
n−1 ,
2
2 n−1 , 1−
2
2 2 2
If χ n−1 , 1− α ≤ X ≤ χ n−1 , α , then H0 is accepted.
2 2
2 2 2 2
The p-value depends whether s <σ 0 or s >σ 0.
p-Value for a One-Sample χ2 Test for the
Variance of a Normal Distribution, Two-Sided
2 ( n−1 )∗s 2
Let the test statistic X = .
σ 20
Week 11
Estimation – III (Discrete: Binomial and Poisson)
Estimation for the Binomial Distribution
Point estimation
Remember: The expected value E(X) and the variance Var(X) of a binomial random variable were:
E(X) = np and Var(X) = npq, respectively.
√
2
E ( ^p )=E ( X i ) ≡ μ= p ,∧¿Var ( ^p )= σ = pq ,∧se ( ^p )= pq
n n n
Then, the number of events X observed out of n cases will be approximately normally distributed
X
with mean np and variance npq. Moreover, the proportion of events ^p= is normally distributed
n
pq
with mean p and variance .
n
This is the case when the sample size n is large enough that the central limit theorem holds. Then:
^p N p ,( pq
n )
Also, since the number of successes in n Bernoulli trials X =n ^p , if above equation is multiplied by n:
X N ( np , npq )
This assumption holds only if:
npq ≥ 5
If the binomial parameter p is unknown, it can be estimated by the sample proportion of events ^p,
and q can be estimated as 1− ^p =^q . Thus, the condition for the assumption to hold can be
approximated as,
n^
pq ≥5
Interval Estimation
Normal – Theory Method for Obtaining a CI for Binomial Parameter p (Wald Method)
An approximate 100% * (1 – α) CI for the Binomial parameter p based on the normal approximation
to the binomial distribution is given by:
^p ± z
1−
α
2 √
∗
^p q^
n
This method is valid only whenn ^p q^ ≥ 5.
A more accurate CI can be computed, especially when normal approximation is not valid, i.e. npq ≥ 5
or n ^p q^ ≥ 5.
Exact Method for Obtaining CI for the Binomial Parameter p (Clopper – Pearson Method)
An exact 100% * (1 – α) CI for the binomial parameter p is given by (p1, p2), where:
n x
α
() α
P ( X ≥ x| p= p1 )= =∑ n ∗p1k∗( 1− p1 ) P ( X ≤ x| p=p 2 )= =∑ n ∗pk2∗( 1− p2 )
2 k=x k
n−k
2 k=0 k
n−k
()
This method is always valid .
x
Computing the expressions such as ∑
k=0
(nk)∗p ∗(1− p )
k
2 2
n−k
is cumbersome. Hence, computer
Also, since the exact confidence limits are accurate to a fixed number of decimal points, we cannot
exactly satisfy the above equation. Thus, we use a more conservative approach, such that:
α α
max ( p1 ) for P ( X ≥ x| p= p 1) ≤ ,∧¿min ( p2 ) for P ( X ≤ x| p= p2 ) ≤
2 2
One Sided Confidence Intervals
For example, if we want to know whether a new drug significantly increases the life expectancy of
cancer patients compared 30% increase by a generic drug, we would only test if the 30% is below the
lower bound. If we could show that 30% is indeed below the lower bound, we would be able to
conclude that the new drug significantly increases the life expectancy.
P ( p> p1 )=1−α
p> ^p −z1−α∗
√ ^p∗q^
n
Upper One-Sided 100% * (1 – α) CI for the Binomial Parameter p – Normal-Theory Method
P ( p< p2 )=1−α
p< ^p + z 1−α∗
√ ^p∗q^
n
Notice that z α is used for two-sided intervals where z 1−α is used for one-sided intervals.
Similar methods can be used to obtain one-sided Cis for the mean and variance of a normal
distribution, for the binomial parameter p using exact methods, and for the Poisson expectation μ.
Point estimation
A person – year is a unit of time defined as 1 person being followed for 1 year in a study.
Let’s assume that the number of events X over T person years is Poisson distributed with parameter
μ= λt . An unbiased estimator of λ is given by:
^λ= X , where X =number of events person− years.
T T
If λ is the incidence rate of events over T person years, T = number of person – years of follow up, and
we assume a Poisson distribution for the events X over T person – years, then the expected value of X
is given by:
E ( X ) λT
E ( X )=λT , thereforeE ( ^λ )= = =λ
T T
Thus, ^λ is an unbiased estimator of λ .
Interval estimation
x± z α ∗√ x .
1−
2
However, for a Poisson distribution, ln(x) is more closely normally distributed than x, and an
approximate variance of ln(x) is 1/x.
z α
1−
2
ln ( x ) ± ≡ ( c 1 ,c 2 )
√x
And the corresponding 100 * (1 – α) CI for µ is given by:
[ exp ( c1 ) , exp ( c 2 ) ]
equations:
∞ x−1 −μ1 k − μ1 k
α e μ1 e μ1
P ( X ≥ x|μ=μ1 )= =∑ ¿ 1−∑
2 k=x k ! k=0 k!
x −μ2 k
α e μ2
P ( X ≤ x|μ=μ2 )= =∑
2 k=0 k !
And x = observed number of events, T = number of person-years of follow-up.
Table 7 in the appendix gives exact CI for 90%, 95%, 98%, 99%, and 99.8% for μ, if observed number
of events (x) ≤ 50.
For small x exact CIs for μ of Poisson distribution is not symmetrical about x.
In some cases, for a rare event which is assumed Poisson distributed, the number of person-years is
unknown/not reported. In these situations, it is still possible to obtain a CI for μ, but not for λ , since
Under H 0:
^p N p0 , ( p0 q 0
n )
If we standardize ^p, subtracting the expected value E( ^p) and dividing by the se of ^p:
^p− p0
z=
√ (p ¿ ¿ 0 q0 )
n
¿
Now, under H 0:
z N ( 0 , 1)
To obtain a better approximation of the binomial by the normal distribution, we apply a continuity
correction.
1
^p − p0 +
2n
if ^p < p0 : z= if ^p ≥ p 0 :
√ (p ¿ ¿ 0 q0 )
n
¿
1
^p − p0−
2n
z=
√ (p ¿ ¿ 0 q0 )
n
¿
This expression can be generalized as:
1
| ^p − p0|− 2
z corr=
√ ( p ¿ ¿ 0 q 0)
n
¿
1
| ^p − p0|− 2 n
z corr=
√ ( p ¿ ¿ 0 q 0)
n
¿
Additionally:
( )
2
1
|^p − p0|− 2n
2 2
x corr = χ1
p0q0
n
With the p-value:
In this case, the p-value can be calculated as the sum of the probabilities of all events that are as
extreme as or more extreme than the sample result obtained.
Procedure: Computation of the p-value for the One-Sample Binomial Test – Exact Method (Two-
Sided)
[ ]
x
()
if ^p ≤ p 0 , p=2∗P ( X ≤ x ) =min 2∗∑ n ∗pk0∗( 1− p0 )n−k , 1
k=0 k
[ ]
n
()
if ^p ≥ p 0 , p=2∗P ( X ≥ x ) =min 2∗∑ n ∗pk0∗( 1− p0 ) n−k , 1
k=x k
Procedure: The Power and the Sample Size of Estimates of a Binomial Test
The power of a normal test can be estimated using large sample procedures.
H 0 : p= p0 vs . H 1 : p ≠ p 0
H 1 : p= p1
Is given by:
power=ϕ
[√ (p 0∗q 0
p 1∗q 1
∗
z α ∗| p0 −p 1|∗√ n
2
√ p 0∗q 0 )]
Then, using this power, we can calculate the sample size needed to conduct a two-sided test at the
significance level α and the probability of finding significant results 1 – β (power), as:
( √ )
2
p ∗q
p 0∗q 0∗ z α + z 1−β∗ 1 1
1−
2
p 0∗q 0
n= 2
( p 1−p 0 )
To calculate one-sided version, it is enough to substitute α is substituted for α /2.
One-Sample Inference for the Poisson Distribution – Large Sample Method
Let μ be the expected value for a Poisson random variable. To test the hypothesis
H 0 : μ=μ 0 vs . H 1 : μ ≠ μ 0
( )
2
|x−μ0|− 12
2 2 2
X =X corr = χ 1 under H 0
μ0
(3) For a two-sided test at level α , H 0 is rejected if ,
2 2
X corr > χ 1 ,1−α
and H 0 is accepted if ,
2 2
X corr ≤ χ 1 ,1−α
(4) The p-value is given by:
P ( χ 21 > X 2corr )
(5) This test should only be used if μ0 ≥10 .
H 0 : μ=μ 0 vs . H 1 : μ ≠ μ 0
The two sided 100% * (1 – α) CI interval for Poisson parameter µ (c1, c2) contains all values µ0 for
which we would accept H0 at confidence level α.
Table 7 in the Appendix contains exact confidence limits for the Poisson expectation µ.
H 0 : μ=μ 0 vs . H 1 : μ ≠ μ 0
( ) ( ( ))
x − μ0 k x−1 k − μ0
e μ0 e μ0
min 2∗∑ ,1 if x< μ 0min 2∗ 1−∑ , 1 if x ≥ μ 0
k=0 k! k=0 k!
Week 12
Midterm II
Week 13
Hypothesis Testing – III (Two-Sample Inference)
In two-sample hypothesis testing the underlying parameters of two populations, with unknown
values, are compared.
In a longitudinal or a follow-up study, the same group of people is followed over time. This
represents a paired-sample design, where each participant is used as their own control.
In a cross-sectional study, the participants in compared groups are evaluated at the same time. This
represents an independent-sample design, where the data points in one sample are unrelated to the
data points in the second sample
Paired t-test (t-test for the difference in means of two paired samples)
Test statistic:
√ [ (∑ (∑ ) ) ]
n n 2
d 2
d− di
, where i
sd i=1 i=1 n=the number of matched pairs
√n n
sd = ,∧¿
n−1
If t> t α ∨t <−t α , reject H 0,
n−1 ,1− n−1 ,1−
2 2
Two-sided 100% * (1 – α) CI for the true mean difference (Δ) between two
paired samples
t α ∗sd t α ∗s d
n−1 ,1− n−1 ,1−
2 2
d− ,d+
√n √n
Thus, before performing a two-sample t-test on the means of independent samples we need a test to
decide if the underlying variances are equal or not.
2
2 2 2 2 s1
The best test for hypothesis H 0 :σ 1=σ 2 vs . H 1 :σ 1 ≠ σ 2 is based on the ratio of variances 2. We
s2
2
s1
reject H 0 if the ratio 2 is too small or too large.
s2
2
s1
The variance ratio 2 follows an F distribution, which is a family of distributions indexed by two
s2
parameters termed the numerator degrees of freedom, and the denominator degrees of freedom.
If the sizes of the tested samples are denoted n1 and n2, then the F distribution with numerator df
of n1 – 1 and denominator df of n2 – 1 is denoted F n −1 , n −1. 1 2
The 100 * pth percentile of an F distribution with d1 and d2 degrees of freedom is denoted by
F d ,d , p.
1 2
Thus:
P ( F d ,d < Fd
1 2 1 ,d 2, p )= p
Also, the lower pth percentile of an F d ,d distribution is the reciprocal of the upper percentile of an
1 2
F d , d distribution:
2 1
1
F d ,d , p=
1 2
F d , d ,1− p
2 1
if F α ≤ F≤ F α , accept H 0
n1−1 ,n2−1 , n1−1 , n2−1 , 1−
2 2
{
p−value= if F ≥1 , then p=2∗P(F n −1 ,n −1> F)
if F< 1, then p=2∗P(F n −1 ,n −1 < F)
1
1
2
It does not matter, for a two-sided test, which sample size is in the numerator. Since a variance ratio >
1 is usually more convenient, the larger variance is put in the numerator as a common practice.
If, as a result of the F-test, we decide that the underlying variances of two samples are not
significantly different, then we can perform a two-sample t-test for the difference in means of two
samples with equal variances.
Since the population variance σ2 is usually unknown, we will estimate it from the sample variances
2 2
s1∧s 2.
However, since the sample size is an important factor for the variance, the best estimate of the
population variance σ2 is given by a weighted average of the two sample variances, with degrees of
freedom for each sample as the weights.
This is called the pooled estimate of the variance from two independent samples:
x 1−x 2
√
2 2
t= , where ( n1 −1 )∗s1 + ( n2−1 )∗s 2
s∗
√ 1 1
+
n1 n2
s=
n1+ n2−2
if t >t α ,∨t<−t α , thenreject H 0,
n1+n2−2 ,1− n1 +n2−2 ,1−
2 2
p−value=
{ if t ≤ 0 ,then p=2∗P ( t n +n −1< t )
1
( x 1−x 2−t
n1+n2−2 ,1−
α
2
∗s∗
√ 1 1
+ , x 1−x 2+ t
n1 n2 n +n1
−2,2
1−
α ∗s∗
2
1 1
+
n1 n 2 √ )
Don’t forget that for both the t-test and the CI, s2 is the pooled variance estimate.
If, as a result of the F-test, we conclude that the underlying variances of the two samples are
significantly different, we will perform a two-sample t-test for independent variables with unequal
variances.
Notice that we don’t use the pooling this time because we assume that the variances are different.
x 1−x 2
t=
√
2 2
s1 s2
+
n1 n 2
( )
2 2 2
s1 s2
+
'
n1 n2
d= ,∧¿
( ) ( )
2 2 2 2 ''
s1 s2 d =largest intager ≤ d '
n1 n2
+
n1−1 n2 −1
if t >t α ,∨t ←t α , thenreject H 0,
d' ' ,1− d' ' , 1−
2 2
( √ √ )
2 2 2 2
s1 s2 s1 s2
x 1−x 2−t α∗ + , x 1−x 2 +t α ∗s∗ +
d ,1−
2
n1 n 2
''
d ' ', 1−
2
n1 n2
The sample size and power can be estimated for two-sample inferences.
The Sample Size Needed for Comparing the Means of Two Normally
Distributed Samples of Equal Size Using a Two-Sided Test with Significance
Level α and Power 1 – β
The Sample Size Needed for Comparing the Means of Two Normally
Distributed Samples of Unequal Size Using a Two-Sided Test with
Significance Level α and Power 1 – β
( )(
2
2 σ2 2
n1 =
σ1+
k
∗ z α + z 1− β
1−
2 ) =sample ¿ the first group ,
2
∆
( k∗σ +σ )∗ z
2
1
2
2
( 1−
α + z 1−β
) =sample ¿ the second group ,
2
2
n2 = 2
∆
n2
where , ∆=|μ2−μ 1|,∧, k= = predicted ratio of thetwo sample sizes
n1
It is possible to detect and treat outliers in the data with different methods.
The pth percentile for the ESD statistic based on a sample of size n is denoted by ES D n , p .
ES Dn ,1−α =
t n−2 , p∗( n−1 )
√ n∗(n−2+t 2
n−2, p )
, where p=1− [ ]
α
2n
We suspect there are outliers in the sample. To test the hypothesis H0: that no outliers are present vs.
H1: that a single outlier is present, with significance level α,
ES Dn ,1−α =
t n−2 , p∗( n−1 )
√ n∗(n−2+t 2
n−2, p )
, where p=1− [ ]
α
2n
(n )
(3) If ESD > ES D n ,1−α ,then we reject H 0∧x is an outlier .
If ESD ≤ ES Dn ,1−α , thenwe accept H 0∧there are no outliers .
In some instances, the standard deviation can get inflated in the presence of multiple outliers. This
reduces the magnitude of the ESD statistic, and it gets harder to identify outliers by this method.
We first need to determine a reasonable upper limit for the number of outliers. This can be given as:
min
([ ] )
n
10
, 5 , where
n
10 [ ]
isthe largets integer ≤
n
10
If there are more than 5 outliers in the dataset, then the underlying distribution is likely to be
nonnormal (given that the sample size is not very large).
k =min
([ ] )
n
10
, 5 , where
n
10 [ ]
is the largets integer ≤
n
10
To test the hypothesis H0: that no outliers are present vs. H1: that there are 1 to k outliers, with
significance level α,
(6) We should use table 9 from the appendix to implement this procedure only if n ≥ 20.
For example, we can place the quantiles of our data on the y-axis, and the quantiles from a standard
normal distribution on the x-axis of the Q-Q plot.
They can say A is better, B is better, or they are both equally good.
Let’s assume this can be expressed with numbers. For ith person, xi is how good the item A is, yi is how
good the item B is, and di = xi – yi.
We want to test H0: Δ = 0 vs. H1: Δ ≠ 0, where Δ is the median, or the 50th percentile of the underlying
distribution of di.
We exclude the people with di = 0 because in this case both items are equally good.
The test will be based on the number of people C for whom di > 0 out of people with nonzero di.
Thus, under null hypothesis H0: Δ = 0, we would expect that P(nonzero di > 0) = ½. Because in that
case C would be equal to its counterpart where nonzero di < 0.
Normal Method
If npq ≥ 5,
n∗1
∗1
or in that case if 2 , and when rearranged,
≥5
2
if n ≥ 20, where n is the number of nonzero d is
Then normal approximation to binomial distribution can be assumed.
C> c 2=
n+1
2 1−
2
n
4√
+ z α ∗ ∨C< c1=
n−1
2
−z α ∗
1−
2
n
4 √
Then H0 is rejected. Otherwise, H0 is accepted.
[ ( √ )]
p=2∗ 1−ϕ
C− ( n+12 )
n
4
if C>
n
2
(√ ) ( n−1
2 )
C−
n
p=2∗ϕ if C <
n 2
4
n
p=1.0 if C=
2
Alternatively:
[
p=2∗ 1−ϕ (|C−D√n|−1 )]if C ≠ D∧ p=1.0 if C=D ,
where C=the number of di > 0∧D=thenumber of d i <0.
Or another alternative:
2 (|C−D|−1 ) 2
Let X = χ 21 under H 0 .
n
Then the two-sided p-value is given as:
p=P ( χ 21> X 2 )
The test is called sign test because we only consider the signs, regardless of the relative magnitude.
Exact method
If n < 20, then exact binomial probabilities must be used to calculate a p-value.
Procedure for Calculation of Exact p-values for Sign Test
( )( ) ( )( )
n C
n 1 n n 1 n n
If C> , p=2∗∑ n If C< , p=2∗∑ n If C= , p=1.0
2 k=C k 2 2 k=0 k 2 2
They can give a score of 1-10 based on how good an item they think.
In such cases, ordinary data may have numerical values, but these values just represent the relative
rank instead of an actual magnitude.
In this case, we will use Wilcoxon Signed-Rank Test, which is a nonparametric analogous to the paired
two-sample t-test.
The test is based on the sum of the ranks, or rank sum (R1), for the group of people with positive di.
If the null hypothesis is true, then the expected value and the variance of the rank sum (when there
are no ties) is given by:
Normal Method
If the number of nonzero di ≥ 16, then the normal approximation can be used for sampling
distribution R1.
Procedure for Wilcoxon Signed-Rank Test (Normal Approximation Method for Two-Sided Level α
Test)
T=
[|
R 1−
n∗( n+1 ) 1
4
− | ]
2
T=
[|
R 1−
n∗( n+1 ) 1
4
− | ]
2
√
n∗( n+1 )∗( 2n+1 )
g 3
t i −t i
24−∑
i=1 48
Where ti is the number of observations within the same tied group and g is the
number of tied groups.
n∗( n+1 )
c. If R1= , then T = 0
4
4. If T > z1− α ,then reject H 0 , otherwise accept H 0 .
2
This formula is easier to compute and valid for both in the absence or presence of ties.
The resulting test statistic and p-value will be the same, if the negative values were used for
computation instead of the positive values. Thus, the procedure can be applied arbitrarily on the
positive or negative differences (preferably on the ones with lower numbers).
Exact Method
If the number of nonzero di < 16, then probability tables such as table 10 in the appendix, must be
used.
1. Combine the data from two groups, and order the values from lowest to highest.
2. Assign ranks to the individual values.
3. If a group has of observations have the same value, then compute the range of ranks for the
group and assign the average rank for each observation in the group.
The test statistic is the sum of the ranks in the first sample (R1). If this sum is large, then the first
sample has higher scores than the other one; and if this sum is small, then the first sample has lower
scores than the other one.
If the number of observations in two groups are n1 and n2, the expected rank-sum in the first group,
E(R1) = n1 * (n1 + n2 + 1)/2, and variance Var(R1) = n1*n2*(n1 + n2 + 1)/12.
Furthermore, the smaller of the two groups must be of size at least 10, and the variable under study
must have an underlying continuous distribution.
Under these assumptions, the sampling distribution of the rank-sum R1 is approximately normal.
Normal Method
Procedure for Wilcoxon Rank-Sum Test (Normal Method)
T=
[|
R 1−
n1∗( n1 +n2 +1 ) 1
2
− | ]
2
n1∗ ( n1 +n2 +1 )
b. If R1 ≠ ∧there are ties,
2
T=
[| R1−
2
−| ]
n1∗( n1 +n2 +1 ) 1
2
√( [ ]
g
∑ t2i −ti
n1∗n 2
12 )
∗ n1+ n2 +1− i=1
( 1 2 )∗( n1 +n 2−1 )
n +n
Where ti is the number of observations in the same tied group, and g is the number
of tied groups.
n1∗( n1 +n2 +1 )
c. If R1= then T =0
2
4. If T > z1− α thenreject H 0 . Otherwise accept H 0 .
2
5. p−value=2∗[ 1−ϕ ( T ) ]
6. This should be used if both n1 and n2 are at least 10, and if there is an underlying continuous
distribution.
( n1∗n2 N
) ( )
2
N +1
Var ( R1 )= ∗∑ r i−
N i=1 2
Where N = n1 + n2 and ri = rank of the ith observation in the combined sample of size of N.
This alternative method is valid in both conditions whether there are ties or not.
Exact Method
If one of the sample sizes is smaller than 10 then exact methods must be used. Table 11 in appendix is
used for this. Under the assumption of there are no ties.