|

Running a Chi-Square Test of Independence – Data Analysis and Intrepretation

Running a Chi-Square Test of Independence

For the purpose of running Chi Square Test of Independence
on the Gapminder dataset I am working on, as indicated in the assignment
instruction, I will have to categorize some of my Gapminder quantitative
variables into categorical variables.

In this sense, I have added another quantitative variable from the Gapminder data to the dataset csv file I will be working with; the new quantitative variable is exports.

The new exports variable:

exports: Exports of goods and services represent the value of all
goods and other market services provided to the rest of the world. They include
the value of merchandise, freight, insurance, transport, travel, royalties,
license fees, and other services, such as communication, construction,
financial, information, business, personal, and government services. They
exclude compensation of employees and investment income (formerly called factor services) and transfer payments.

 

It is this exports variable I will categorise to 2 level categorical response variable in order to be able to run Chi Square Test of Independence on my work.

I have subsequently, updated My Personal Codebook to include this new variable.

See updated codebook here:

https://docs.google.com/document/d/177YfOjdk4oekFu20OLt4fgmu-n7cgRULAJ_Kd9KdYaM/edit?usp=sharing

 

Secondly, the purpose of the Chi Square Test of Independence,
I have slightly changed the research question.

The new research question is:

Is there an association or relation between Inflation and Exports of Ghana?

 

Hypothesis Testing

The Null and Alternate Hypotheses:

From the above research question, the Null Hypothesis (Ho) is that there is no association / relation between Inflation and Exports of the people of Ghana.

Whereas the Alternate Hypothesis (Ha) states that there is an association /
relation between Inflation and Exports of the people of Ghana.

 

Sample:

Sample is the data from the Gapminder dataset with focus on Ghana

 

Assessing the evidence:

This is done by Running Chi Square Test of Independence on the hypotheses.

I do this by using running the test using the Python program.

 

MY PYTHON PROGRAM CODE:

 

 

 

CODE OUTPUT:

<<<<<<<<<<<<< CODE OUTPUT BEGIN >>>>>>>>>>>>>>>>>>>

describe inflation Category

count           51

unique           4

top       (-4, 32]

freq            37

Name: inflationCategory, dtype:
object

 

 

inflation category

(-4, 32]     37

(32, 64]      9

(64, 96]      4

(96, 128]     1

dtype: int64

 

 

describe Exports Category

count                  51

unique                  2

top       [3.338, 20.254]

freq                   26

Name: exportsCategory, dtype:
object

 

 

Exports category

[3.338, 20.254]     26

(20.254, 48.802]    25

dtype: int64

 

 

inflationCategory  (-4, 32]
(32, 64]  (64, 96]  (96, 128]

exportsCategory

[3.338, 20.254]          16         6         3          1

(20.254, 48.802]         21         3         1          0

 

 

inflationCategory  (-4, 32]
(32, 64]  (64, 96]  (96, 128]

exportsCategory

[3.338, 20.254]    0.432432
0.666667      0.75          1

(20.254, 48.802]   0.567568
0.333333      0.25          0

 

 

chi-square value, p value,
expected counts

(3.6574740124740135,
0.30090520911852703, 3, array([[ 18.8627451 ,
4.58823529,   2.03921569,   0.50980392],

[ 18.1372549 ,   4.41176471,
1.96078431,   0.49019608]]))

 

 

please find graph for analysing further the values

https://drive.google.com/file/d/0B2KfPRxy4ootVzR3R3RoNW9iOEk/view?usp=sharing

<<<<<<<<<<<<<CODE OUTPUT ENDED>>>>>>>>>>>>>>>>>>>

 

 

DRAWING CONCLUSION (SUMMARY):

Model Interpretation for Chi-Square Tests:

When examining the relation /association between Inflation (categorical explanatory variable) and Exports (categorical response variable) of Ghana, we can see that the p-value from the Chi-Square Test results is p= 0.3009 with an associated chi-square value, X2 = 3.657

 

From this p-value and its associated chi-square value the test is significant and therefore I will accept the Null Hypothesis (Ho) that there is no association / relation between Inflation and Exports of the people of Ghana

 

Model Interpretation for post hoc Chi-Square Test results:

However, since there are different categories of inflation rate, to reduce a Type Error between each of the various exports levels with respect to the inflation

I ran post hoc Chi-Square Test for each of the values of the explanatory variable – inflation. Hence two by two Chi-Square Tests were run for each of the values in my explanatory categorical variable.
There were a total of six combinations of these individual tests.

With the help of the Bonferroni Adjustment test method most of these compared variables were not very far or different from each other. Hence I will accept the Null Hypothesis (Ho) that there is no association / relation between
Inflation and Exports of the people of Ghana.

Want more information like this?

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *