Skip to main content

Median test

 Non- Parametric test

Median test

Median test is also a Non-Parametric test and it is alternative to Parametric T test. The median test is used when we are interested to check the two independent sample have same median or not. It is useful when data is discrete or continuous and if data is in small size. 

Assumptions: 

I) the variable under study is ordinal scale

II) the variable is random and Independent.


The stepwise procedure for computation of median test for two independent sample :

Step I :- firstly we define the hypothesis

Null Hypothesis is the two independent sample have same median. 

Against

Alternative Hypothesis is the two independent sample have different median. 

Step II:- In this step we combine two sample data. And calculating the median of combined data.

Step III:- after that for testing hypothesis we constructing the (2x2) contingency table. For that table we divide the sample into two parts as number of observation above and below to the median for both sample then the formulated table is 

 

Sample I

Sample II

Total

No. of observations less then median

a

b

a+b

No. of observations greater than or equal to median

 c

d

c+d

Total

a+c

b+d

n

Here we deciding the data first sample as number of observation less than median is a and the number of observations greater then or equal to median is c. In the above table. Similarly for second sample the number of observation in second sample is less than median is b and number of observations are greater than or equal to median is d. Then calculating marginal totals are (a+c), (b+d),(c+d),(a+b). 

the selection of test statistics is based on following conditions.

I  .If  the sample size is large and expected frequencies greater then 5 we use chi-square test. 

χ2 = (∑ (O-E)2 ) / E

II  .If  the sample size is Small and expected frequencies less then 5 we use chi-square with yates correction. 

χ2  = {[n (|ad-bc|-(n/2))^2]/ (a+b)x(c+d)x(a+c)x(b+d)} 

III. If number of observation very less than and expected frequencies less then 5  then we  use fishers exact test. 


If expected frequency is less than 5 then use corrected formula of chi-Squaee test. 


( The test statistics is chi-square and it is calculated as 

χ2  = χ2 = (∑ (O-E)2 ) / E is calculated value

Corrected formula of chi-Square - in this step we defining the test statistics as chi-square and it is calculated as 

χ2  = {[n (|ad-bc|-(n/2))^2]/ (a+b)x(c+d)x(a+c)x(b+d)}  is calculated value

where n = a+b+c+d  )

Decision  Rule:- for taking decision about hypothesis the critical value for test statistics is obtained in table of critical value table of chi-square. 

If the calculated chi-square is less than the tabulated chi-square we accept the null hypothesis at  ∝ % of level of significance. Otherwise reject the null hypothesis.

  

critical value for chi-square for 1 degrees of freedom is 3.841 at 5% of level of significance and 

6.635 at 1% of level of significance

Small sample test :- 

Fisher's Exact Test:

If we are interested to check the two independent sample are drawn from population with unique median or not. In that case we use Media rest but there some conditions to use median test. In this case if the sample size( n1+n2) less than 20 and one or more expected cell frequencies of (2x2) contingency table is less 5 then we use Fisher's exact test.

In test consist of probability associated with all possible combination of (2x2) contingency table.

Assumptions:

I) the sample should be random and Independent.

II) the marginal totals of contingency table is fixed.


For Fisher's exact test follow following procedure:- 

Step I :- we are interested to test the two independent sample are drawn from population with unique median or not. Then we use this test and for testing we set hypothesis as Null hypothesis is that the two samples have same median. Against the Alternative hypothesis is the two samples have different median. 

Step II -: for performing test firstly we constructing the (2x2) contingency table. (Same as in median test) For that table we divide the sample into two parts as number of observation above and below to the median for both sample then the formulated table is 

 

Sample I

Sample II

Total

No. of observations less then median

a

b

a+b

No. of observations greater than or equal to median

 c

d

c+d

Total

a+c

b+d

n

Here we deciding the data first sample as number of observation less than median is a and the number of observations greater then or equal to median is c. In the above table. Similarly for second sample the number of observation in second sample is less than median is b and number of observations are greater than or equal to median is d. Then calculating marginal totals are (a+c), (b+d),(c+d),(a+b) fixed for each possible combination.

Step III:- this test based on the probability of  all possible combinations of(2x2) contingency table. For obtaining all possible combination.

We define ns = smallest marginal Total, this obtained form table. For then if ns= n2= (c+d) then possible combination of  (2x2) contingency table are obtained as (i,j) = (0, n2), (1, n2-1) ...........(n2,0)  using this combination we prepare table with fixed original marginal Total. And computing the all possible value of table as 

Pi j = {(a+b)!x(c+d)!x(b+d)!x(a+c)!}/ {n! x a! x b! x c! x d!}

Step IV:- in this step defining test statistics is P-value and is obtained as adding Pi j  all probabilities which are less than or equal to the actual or original Pi j  of (2x2) contingency table.


Decision rule : If P-value is less than or equal to ∝ % level of significance then we Reject null hypothesis.

the fisher's exact test is a statistical test used to determining the significance of the association between two categories. the fisher's exact the is particularly  used when the sample size is small and the assumption are required for other test, such as the assumptions of chi-square test are not met then fisher's exact test is used. it provides a way to determine if the observed association between two variable is statistically significant, it gives idea about the relation between the variable investigate. 

for example : the fisher's exact test is used in clinical research to assess the association between the two categorical variables. e.g. it is used to examine the relation between a specific treatment and its outcome.

 Example: 10 boy and 15 girls were observed during the two play session. every children was scored for the degree of aggregation as: 

Boy: 56 59 72 65 113 65 141 51 20 65

girl: 55 40 22 56 25 7 58 9 20 46 26 36 50 31 45

use the median test to test there is difference between the score of boys and girl.

Answer:  for testing there is difference between the score of boys and girl.

 firstly we define the hypothesis

Null Hypothesis : there is no significant difference between the score of boys and girl.

Against

Alternative Hypothesis : there is significant difference between the score of boys and girl.

In this step we combine two sample data. And calculating the median of combined data.

7, 9, 20,20, 22, 25, 26, 31, 36, 40, 45, 46, 50, 51, 55, 56, 56,58, 59, 65, 65, 65, 72, 113, 141.

Median = size of  { (n+1) / 2} th observation

                =  size of 13 th observation 

Median = 50 

 after that for testing hypothesis we constructing the (2x2) contingency table. For that table we divide the sample into two parts as number of observation above and below to the median for both sample then the formulated table is 

 

Sample I

Sample II

Total

No. of observations less then median

1

11

12

No. of observations greater than or equal to median

 9

4

13

Total

10

15

25


here n1 + n2 = 25 is between 20 to 40 then we check the expected frequency of table.




Sample I

Sample II

No. of observations less then median

(10x12)/25= 4.8

(12x15)/25=7.2

No. of observations greater than or equal to median

 (13x10)/25=5.2

(15x13)/25=7.8

the one sell have less than 5 expected frequency then we use chi-square statistics with yates correction for contingency table 

χ2  = {[n (|ad-bc|-(n/2))^2]/ (a+b)x(c+d)x(a+c)x(b+d)} 

χ2  = {[25 (|99-4|-(25/2))^2]/ 12x10x15x13} 

χ2 = 7.271 it id calculated 

and table value is 3.841 i.e. χ2  df, with 5% l.o.s.

the calculated chi-square is greater than the tabulated chi-square we Reject  the null hypothesis at  5 % of level of significance. 

hence there is significant difference between the score of boys and girl. 

Fisher's Exact Test Example:

Example 1:- We are interested in two independent sample are drawn from population having identical median or not. For the following given data. 

 

Sample I

Sample II

No. of observations less then median

10

2

No. of observations greater than or equal to median

 3

5

Use appropriate test. At 5 % level of significance. 

Solution:- for given example we want to test the two sample are drawn from population having identical median or not for testing we  setting the Hypothesis as

 
Null Hypothesis :- the two independent sample drawn from population having identical median.
Alternative Hypothesis:- the two independent sample drawn from population having different median.

for performing test first we calculate marginal total.

 

Sample I

Sample II

Total

No. of observations less then median

10212

No. of observations greater than or equal to median

 3

5

8

Total

137

20

now we check the expected frequencies.



Sample I

Sample II

No. of observations less then median

(12x13)/20= 7.8

(12x7)/20=4.2

No. of observations greater than or equal to median

 (13x8)/20=5.2

(7x8)/20=2.8

now we see the two expected frequencies are less then 5. and number of observation are 20, in this situation fisher's exact test is more appropriate.

now we find the ns=smallest marginal total = min(R1,R2,C1,C2)

Where R1 and R2 are total of first and second row respectively. 
C1 and C2 are total of first and second column respectively. 
Here 7 is smallest marginal Total corresponding to C2
There for we prepare the all possible combination as (0,7 ),(1,6),(2,5),(3,4),(4,3),(5,2),(6,1),(7,0). Using this all possible combinations we prepare (2x2) contingency table for each combination with fixed marginal totals. 
Then we calculating Pij for each (2x2) contingency table. 
Pij calculated as

Pi j = {(a+b)!x(c+d)!x(b+d)!x(a+c)!}/ {n! x a! x b! x c! x d!}

1) for (0,7) 

 

Sample I

Sample II

Total

No. of observations less then median

12

0

12

No. of observations greater than or equal to median

 1

7

8

Total

13

7

20

Pi j = {(a+b)!x(c+d)!x(b+d)!x(a+c)!}/ {n! x a! x b! x c! x d!}

Pi j = {13!x7!x12!x8!}/ {20! x 12! x 0! x 1! x 7!}
Pi j = 0.0001

2)for (1,6)

 

Sample I

Sample II

Total

No. of observations less then median

11

1

12

No. of observations greater than or equal to median

 2

6

8

Total

13

7

20

Pi j = {(a+b)!x(c+d)!x(b+d)!x(a+c)!}/ {n! x a! x b! x c! x d!}
Pi j = {13!x7!x12!x8!}/ {20! x 11! x 1! x 2! x 6!}
P2 =0.0043
 3) for (2,5)

 

Sample I

Sample II

Total

No. of observations less then median

10

2

12

No. of observations greater than or equal to median

 3

5

8

Total

13

7

20

Pi j = {(a+b)!x(c+d)!x(b+d)!x(a+c)!}/ {n! x a! x b! x c! x d!}
Pi j = {13!x7!x12!x8!}/ {20! x 10! x 2! x 3! x 5!}
P3 =0.0477 is the Pij of original value
4)for (3,4) 

 

Sample I

Sample II

Total

No. of observations less then median

9

3

12

No. of observations greater than or equal to median

 4

4

8

Total

13

7

20

Pi j = {(a+b)!x(c+d)!x(b+d)!x(a+c)!}/ {n! x a! x b! x c! x d!}
Pi j = {13!x7!x12!x8!}/ {20! x 9! x 3! x 4! x 4!}
P4 =0.1987
5) for (4,3)

 

Sample I

Sample II

Total

No. of observations less then median

8

4

12

No. of observations greater than or equal to median

 5

3

8

Total

13

7

20

Pi j = {(a+b)!x(c+d)!x(b+d)!x(a+c)!}/ {n! x a! x b! x c! x d!}
Pi j = {13!x7!x12!x8!}/ {20! x 8! x 4! x 5! x 3!}
P5 =0.3576
6) for (5,2)

 

Sample I

Sample II

Total

No. of observations less then median

7

5

12

No. of observations greater than or equal to median

 6

2

8

Total

13

7

20

Pi j = {(a+b)!x(c+d)!x(b+d)!x(a+c)!}/ {n! x a! x b! x c! x d!}
Pi j = {13!x7!x12!x8!}/ {20! x 7! x 5! x 6! x 2!}
P6 =0.28
7) for (5,2)

 

Sample I

Sample II

Total

No. of observations less then median

6

6

12

No. of observations greater than or equal to median

 7

1

8

Total

13

7

20

Pi j = {(a+b)!x(c+d)!x(b+d)!x(a+c)!}/ {n! x a! x b! x c! x d!}
Pi j = {13!x7!x12!x8!}/ {20! x 6! x 6! x 7! x 1!}
P7 =0.0954
8) for (7,0)

 

Sample I

Sample II

Total

No. of observations less then median

5

7

12

No. of observations greater than or equal to median

 8

0

8

Total

13

7

20

Pi j = {(a+b)!x(c+d)!x(b+d)!x(a+c)!}/ {n! x a! x b! x c! x d!}
Pi j = {13!x7!x12!x8!}/ {20! x 5! x 7! x 8! x 0!}
P8 =0.0102

After calculating all  possible value of Pi j . Then finding the P-value 

P-value is sum of all Pi j which are less than or equal to Pi j of original (2x2) contingency table. 
Therefore P- value is 
P-value = .0.0001 + 0.0102 + 0.0477 + 0.0043= 0.062
For taking Decision we comparing P- value with ∝% level of significance 
Here P-value(0.062) is greater than level of significance 0.05 then we accept the null hypothesis and conclude that the two samples are drawn from population have identical median. 


 



Comments

Popular posts from this blog

B. Com. -I Statistics Practical No. 1 Classification, tabulation and frequency distribution –I: Qualitative data.

  Shree GaneshA B. Com. Part – I: Semester – I OE–I    Semester – I (BASIC STATISTICS PRACTICAL-I) Practical: 60 Hrs. Marks: 50 (Credits: 02) Course Outcomes: After completion of this practical course, the student will be able to: i) apply sampling techniques in real life. ii) perform classification and tabulation of primary data. iii) represent the data by means of simple diagrams and graphs. iv) summarize data by computing measures of central tendency.   LIST OF PRACTICALS: 1. Classification, tabulation and frequency distribution –I: Qualitative data. 2. Classification, tabulation and frequency distribution –II : Quantitative data. 3. Diagrammatic representation of data by using Pie Diagram and Bar Diagrams. 4. Graphical representation of data by using Histogram, Frequency Polygon, Frequency Curve and     Locating Modal Value. 5. Graphical representation of data by using Ogive Curves and Locating Quartile Values....

Index Number

 Index Number      Introduction  We seen in measures of central tendency the data can be reduced to a single figure by calculating an average and two series can be compared by their averages. But the data are homogeneous then the average is meaningful. (Data is homogeneous means data in same type). If the two series of the price of commodity for two years. It is clear that we cannot compare the cost of living for two years by using simple average of the price of the commodities. For that type of problem we need type of average is called Index number. Index number firstly defined or developed to study the effect of price change on the cost of living. But now days the theory of index number is extended to the field of wholesale price, industrial production, agricultural production etc. Index number is like barometers to measure the change in change in economics activities.   An index may be defined as a " specialized  average designed to measure the...

Non- Parametric Test: Run Test

Non- Parametric Test  A Non-Parametric tests is a one of the part of Statistical tests that non-parametric test does not assume any particular distribution for analyzing the variable. unlike the parametric test are based on the assumption like normality or other specific distribution  of the variable. Non-parametric test is based on the rank, order, signs, or other non-numerical data. we know both test parametric and non-parametric, but when use particular test? answer is that if the assumption of parametric test are violated such as data is not normally distributed or sample size is small. then we use Non-parametric test they can used to analyse categorical data  or ordinal data and data are obtained form in field like psychology, sociology and biology. For the analysis use the  some non-parametric test that are Wilcoxon signed-ranked test, mann-whiteny U test, sign test, Run test, Kruskal-wallis test. but the non-parametric test have lower statistical power than ...

Statistical Inference

 Statistical Inference: The Power of Statistical Inference in Data Analysis Statistical Inference: Drawing Meaningful Conclusions from Data In a data analysis, The statistical inference is a  a powerful tool for drawing meaningful conclusions from a sample of data  and making inferences about a larger population. It enables us to make confident predictions, understand relationships, and uncover valuable insights that can inform decision-making and shape various fields of study. At its core, statistical inference involves using statistical methods to analyse sample data and extend the findings to the broader population. This approach is necessary because it is often impractical or impossible to collect data from every individual or element of interest. Instead, we carefully select a representative sample and employ statistical techniques to infer information about the larger population. The first aspect of statistical inference is estimation. Estimation allows us to estima...

B. Com. I OE - II Practical No. 3 Scatter Plot.

  Practical No. 3   Scatter Plot.  Correlation In previous blog we discussed about the measure central tendency and Dispersion to use to study the variable. the correlation is a statistical concept that allows us to measure and understand the relationship between two or more variables. it provided a valuable information about that variables. e.g. price and demand of commodity, income and expenditure of family, height and weight of group of persons. their we use the relation   between this two variables. in above examples we see the one variable increases other variable is also changes in same or opposite direction.  definition: Correlation is statistical tool which study the relationship between two or more variables. for analysis of correlation various method and techniques are used.  example: i. Demand and supply of product                               ...

Non-Parametric Test 1.Sign test

Types of Non-Parametric Test : the non-parametric test is Broadly divided into three categories as: 1. One-sample Test  2.Two-sample test 3. K-sample test In this blog we discuss the one-sample tests,  there are four types of one-sample non-parametric test as follows:  1. Run Test. 2.Sign Test 3. Wilcoxon Sing-Rank test 4. Kolmogorov-smirnov test. first we discuss the sign test. 1.Sign Test The sign test id one of the very simplest non-parametric test. the test is based on signs (i.e. plus and minus signs) hence is called sign test. the non-parametric test are alternative to the parametric one, therefore the sign test is alternative to parametric T-test, is used to test the median of population instead of mean of population. (i.e. Parametric T-test is used to testing mean of population and sign test is used to testing the median of the population they are alternative to each other when the data follows assumption of T-test we use parametric t-test, but i some situation th...

Statistical Inference Practical: Point Estimation by Method of Moment

 

Statistical Inference I ( Theory of Estimation) : Unbiased it's properties and examples

 📚Statistical Inference I Notes The theory of  estimation invented by Prof. R. A. Fisher in a series of fundamental papers in around 1930. Statistical inference is a process of drawing conclusions about a population based on the information gathered from a sample. It involves using statistical techniques to analyse data, estimate parameters, test hypotheses, and quantify uncertainty. In essence, it allows us to make inferences about a larger group (i.e. population) based on the characteristics observed in a smaller subset (i.e. sample) of that group. Notation of parameter: Let x be a random variable having distribution function F or f is a population distribution. the constant of  distribution function of F is known as Parameter. In general the parameter is denoted as any Greek Letters as θ.   now we see the some basic terms :  i. Population : in a statistics, The group of individual under study is called Population. the population is may be a group of obj...

B. Com. I OE - II Practical No. 4 Karl Pearson's correlation coefficient

  Practical no. 4 Karl Pearson's correlation coefficient  Correlation In previous blog we discussed about the measure central tendency and Dispersion to use to study the variable. the correlation is a statistical concept that allows us to measure and understand the relationship between two or more variables. it provided a valuable information about that variables. e.g. price and demand of commodity, income and expenditure of family, height and weight of group of persons. their we use the relation   between this two variables. in above examples we see the one variable increases other variable is also changes in same or opposite direction.  definition: Correlation is statistical tool which study the relationship between two or more variables. for analysis of correlation various method and techniques are used.  example: i. Demand and supply of product                           ...