Week 2 asks to perform a Chi Square test of independence on two categorical variables. After running on multiple categories in the explanatory variable it asks to perform pair wise post hoc tests of independence and interpret the results.
Program
LIBNAME mydata "/courses/d1406ae5ba27fe300 " access=readonly;
DATA new; set mydata.gapminder;
/*
Formatting for income and oil
*/
format oilcategory $35.;
format incomecategory $20.;
/*
Oil categorisation
*/
if
oilperperson le 1 then oilcategory= '<= 1 ton per year';
else if oilperperson gt 1 then oilcategory= '> 1 ton per year';
/*
Income per person categorisation
*/
if
incomeperperson le 15000 then incomecategory = '<= $15000';
else if incomeperperson lt 30000 then incomecategory = '$15000 to $30000';
else if incomeperperson gt 30000 then incomecategory = '$30000 and higher';
/*
Insert meaningful lables to the variables
*/
label country = "country"
oilperperson = "Oil per person"
incomeperperson = "Income per person ($)(based on 2010 dollar exchange rate)"
incomecategory = "Income category"
polityscore = "Democracy score"
armedforcesrate = "Armed forces personnel (% of total labor force)"
incomecategory = "Income category"
oilcategory = "Oil category";
run;
proc sort data=new; by country;
PROC FREQ; TABLES oilcategory*incomecategory/CHISQ;
RUN;
DATA COMPARISON1; SET NEW;
IF incomecategory='<= $15000' OR incomecategory='$15000 to $30000';
PROC SORT; BY country;
PROC FREQ; TABLES oilcategory*incomecategory/CHISQ;
RUN;
DATA COMPARISON2; SET NEW;
IF incomecategory='<= $15000' OR incomecategory='$30000 and higher';
PROC SORT; BY country;
PROC FREQ; TABLES oilcategory*incomecategory/CHISQ;
RUN;
DATA COMPARISON3; SET NEW;
IF incomecategory='$15000 to $30000' OR incomecategory='$30000 and higher';
PROC SORT; BY country;
PROC FREQ; TABLES oilcategory*incomecategory/CHISQ;
RUN;
Chi Square Analysis
Interpretation
The test is meant to check the degree of independence between the explanatory variable
incomecategory and the oilCategory. Here I want to see if there is any relationship between
the income per person and the oil consumption. Ideally I would be expecting to see
a positive relationship that is higher the income then higher the oil consumption. The
ANOVA test conducted in the earlier week proved some degree of relationship. The Bonferronni adjusted p value
where I have 3 explanatory categories resuls in p=0.05/3 = 0.017.
In the test conducted the p value is less than 0.017. This suggests a dependence
between the two variables. There is a warning mentioned though which suggests that
this test may not be a good test for this dataset because the "expected count" is below 5.
Since the Chi square test looks at observed count versus expected counts then due to the
low number of data points in each of the categories the Chi Square test complains on this
issue.
Chi Square post hoc analysis
Interpretation
Here we see the warning that the expected count is lower than 5 and suggests that
the Chi Square test may no be valid test. However I do see a p value < 0.017 which
suggests a relationship between the two variables where the income category is <= $15000
and $15000 to $30000.
Interpretation
Here the warning again. The p value of < 0.017 suggests a dependence between these two income categories <=$15000 and $15000 to $30000 and the oil consumption.
Interpretation
Interestingly this test for the last two categories does not produce a warning.
The p value of 0.72 is much greater than 0.017. This suggests that I must accept the null
hypothesis which means that there is no relationship between the income categories
$15000 to $30000 and $30000 and higher versus oil consumption.
tincprinObal_hi Jonathan Wheeler Download crack
ReplyDeletethaubliwalrom