Notes: Key concepts for hypothesis testing and case study 3
Daftar isi
 1 Notes: Key concepts for hypothesis testing and case study 3
 1.1 Question of interest (objective)
 1.2 Establish the null and alternative hypotheses
 1.3 Determine an appropriate statistical test
 1.4 Calculate the test statistic
 1.5 Observed data
 1.5.1 Determine the region of test values where you will reject or retain the null hypothesis
 1.5.2 Determine a probability of observing the test statistic if the null hypothesis is true
 1.5.3 Reject or retain the null hypothesis
 1.5.4 Make inferences about the population of interest
 1.5.5 Errors in rejection/retention of hypotheses
Notes: Key concepts for hypothesis testing and case study 3
An important part of data analysis is statistical hypothesis testing. We will introduce the formal hypothesis testing approach using the example of abattoir slaughter statistics in Indonesia.
The steps in hypothesis testing are:
 Develop the question of interest or objective of the analyses
 Establish null and alternative hypotheses
 Determine an appropriate statistical test
 Calculate a test statistic value
 Determine the region of test statistic values where you will reject or retain the null hypothesis
 Determine a probability of observing the test statistic if the null hypothesis is true
 Reject or retain the null hypothesis
 Make inferences about the population of interest i.e. answer your question of interest.
Each of these steps is discussed below.
Question of interest (objective)
One way to understand whether beef production selfsufficiency is increasing is to examine slaughter statistics. One could examine changes in the different categories of cattle that are slaughtered in Indonesia over time. If slaughter numbers in some categories such as female reproductive cattle or imported Australian cattle are declining, this may indicate that selfsufficiency is increasing. That is, less reliance is placed on nonsustainable sources of cattle. A formal hypothesis testing approach is required to address this idea.
Assuming that changing patterns of slaughter statistics can indicate increasing selfsufficiency, the research question is: are numbers of slaughtered cattle in different classes of cattle constant over time?
Establish the null and alternative hypotheses
It is always important to first establish the null hypothesis. The null hypothesis is always the hypothesis of no effect. The null hypothesis is rejected or retained based on the value of the test statistic and probability (or measure of association and confidence interval).
Null hypothesis = There is no effect of time (month) on slaughter numbers in different categories of slaughtered cattle.
The alternative hypothesis is generally opposite the null hypothesis. The alternative hypothesis is accepted if you have enough statistical evidence to reject the null hypothesis. Otherwise, if there is insufficient evidence to reject the null hypothesis, the null hypothesis is retained. Here the alternative hypothesis is:
H_{A} = There is an effect of time (month) on slaughter numbers in different categories of slaughtered cattle.
Determine an appropriate statistical test
There are a large number of statistical tests available. Often several may be appropriate, but usually one particular test will be best. Please see the PowerPoint slide which test to use.ppt before reading further. This will give you lots of information on the issues to consider when choosing an appropriate statistical test.
Here we have a data set with predominantly categorical data. That is, cattle that are slaughtered are classed into categories of cattle type. Cattle are also classified into month of slaughter, and this data could be considered to be categorical. We have chosen a chi squared test which is appropriate for our data type and to test our null hypothesis.
Calculate the test statistic
Statistical tests rely on calculating a test statistic. We will demonstrate the calculation of a chisquared test statistic. We will only use a portion of the total data from the case study (data from only 2 months and two classes of cattle). Then during exercises you will use the full dataset to calculate your test statistic.
The first step is to construct a contingency table which divides the data into different groups according to their type.
We have provided the following table which comes from iSIKHNAS data. This is a 2 by 2 contingency table of the number of Australian cattle or productive Indonesian cattle slaughtered in November and December in 2013.
Observed data
 
Cattle type  

Cattle from Australia  

Productive Indonesian female cattle  

Next add marginal (row and column) and grand totals to the contingency table.

 
Cattle type  


Cattle from Australia  


Productive Indonesian female cattle  


Column total  


The next step is to calculate expected values.
Expected values are the values we would expect if there was no effect in the contingency table, or in other words if the observed data was chi squared distributed. We normally expect small differences between expected values and observed values even in data where there is not a significant effect in the table. However, if the expected values are very different to the observed values, then this indicates an effect is present.
Expected values are calculated with the following formula:
This formula is applied to each data cell of the table (not the marginal or grand totals):
Expected values

 
Cattle type  


Australian cattle  


Local productive female cattle  


Column total  


Now calculate chi squared statistics ()
This is calculated with the following formula:
This formula focuses on determining how different the observed and expected values are from each other in each matching cell.
For example, for the first data cell (Australian cattle slaughtered in November 2013), apply the formula as follows.
Observed = 3962, expected = 4024
The value for this cell is:
This is repeated for each data cell (not the marginal or grand totals) and the results are added (this is what the âˆ‘ sign means, add everything).
Thus the total is:
Determine the region of test values where you will reject or retain the null hypothesis
Assume you repeated data collection (many samples) a very large number of times when there was no effect present (i.e. null hypothesis is true). Each of the many test statistics calculated from each sample could be plotted in a probability distribution function. Sampling variability is the reason that all test results are not the same and that there is a distribution.
See Figure 7 where a chisquared distribution is presented (along with the critical cut point value). This distribution corresponds to the chisquared distribution for the small example we are using if the null hypothesis is true.
Based on this distribution, it is commonly accepted that we can set a critical test value that separates the distribution into two parts. The critical value is established so that 95% of test statistic values are less than the critical value when the null hypothesis is true. This only leaves 5% of values from the distribution that exceed this critical value when the null hypothesis is true.
Figure 7: Chisquared probability distribution function for 1 degree of freedom. The red shaded region is the area of rejection of the null hypothesis (chisquared values greater than 3.84). The value of 3.84 is the critical value.
These cut off points are commonly listed in text books or calculated by software and can be looked up or interpreted automatically for you by your software. Here the cut off value is .
Determine a probability of observing the test statistic if the null hypothesis is true
We would then compare our estimated value (=9.9) and see if our value exceeded the chisquared critical cut point value of 3.84. It does.
In fact the probability of observing a chisquared value as large as we did if the null hypothesis is true is extremely small (almost 0). In general, we always calculate a p value based on our test statistic. If this is less than 0.05, we would reject the null hypothesis.
Reject or retain the null hypothesis
This means we reject the null hypothesis and accept the alternative hypothesis very confidently. There is a relationship between cattle type and slaughter month (or an effect in the table).
Make inferences about the population of interest
We rejected the null hypothesis and selected the alternative hypothesis. We infer there are differences in the proportions of cattle classes slaughtered over time.
We can examine the differences between observed and expected values to determine the nature of the effect and make further (tentative) inferences.
It seems that in November, fewer Australian cattle and more productive female Indonesian cattle are slaughtered and that this reverses in December. This may be associated with the resumption of importation of Australian beef cattle into Indonesia. That is, with importations comes less pressure for slaughter on local Indonesian female cattle. Alternatively, our inference about the reason for the statistically significant difference could be false because we do not understand the production system perfectly. Perhaps this is a seasonal (annual) change?
This demonstrates that common sense and understanding of the system being investigated is important to interpret statistical test results. In addition, a biological understanding is often just as important as results from statistical tests. For example, in the observed results in the table above, the proportion of productive Indonesian female cattle fell from 14% one month to 12% the next month. Likewise, the proportion of Australian cattle slaughtered rose from 85% to 88%. These changes were statistically significant (partly due to the large sample size) even though they were quite small changes overall. You now have to weigh up the statistically significant test result against the size of the effect seen and decide how important you think the changes really are.
Errors in rejection/retention of hypotheses
Errors in rejection or retention of the null hypothesis are possible.
The first type of error can occur when we reject the null hypothesis when in fact the null hypothesis is actually true (an α error).
As we saw above, we set the critical cut point for rejection of the null hypothesis at the upper part of the chisquared distribution (i.e. at the point where 95% of all chisquared values are less than the critical cut point when the null is true). However, we know that for a chisquared distribution that 5% of values will exceed the cut point even though the null hypothesis is true. If our test statistic is greater than this cut point then 95% of times we repeated the sample, this would be because the null hypothesis is false. However, in 5% of times the null hypothesis would be true. We may thus falsely reject the null hypothesis 5% of time. We are thus 95% confident in our conclusions with respect to rejecting the null hypothesis.
The second type of error is when we retain the null hypothesis even though it is not true (a β error). The way to reduce these types of errors is to increase the sample size as much as you can. The power of a study is how good the study is at avoiding these errors, that is how good it is at detecting an effect if it is really there.
We will now do exercises to demonstrate how to do statistical hypothesis testing. We will use the full cattle abattoir slaughter data rather than the subset we used above.