## We have seen this curious expression in two setting now in the use of t-test and when using the Chi-squared test.What exactly are degrees of freedom,anyway?                                                                         More specifically, let's look at to situations where these words come up.The expression

(where x mean is the average of the xs),is associated with - 1 degree of freedom. Similarly,in a 2 * 2 table of counts,we always say the chi-squared statistic has one degree  of freedom .The general rule is: Degree of freedom the number of data points to which you can assign any value.Let's see how to apply this rule, when we look at the expression sum(xi-mean x)^2, there are N terms in the sum. Each term is a squared difference between an observation x and the average x mean of all the xs. Let us look at these differences and write them down.                                                                                              We have  d1=xi- mean x , d2=x2-mean x.........dN-mean x.
There are differences di, but notice that these must always sum to 0. Adding up all of the value on the right-hand sides gives a sum of the xs minus N times there average. The d must sum to 0 no matter what values the x's are.                                                                                                    So how many differences d can we freely chose to be any values we want, and still have them add up to 0? The answer is all of them, except for the  last one. The  last one  is determined by all of the others so that they all sum to 0.Notice also that it does not matter which d we call the "last". We can freely choose , N-1 values and the one remaining value is determined by all of the others. Now let us examine the use of degree of freedom when discussing the chi-squared test, As an example, let us return to the data given below.

The chi-squared statistic measures the association of rose and columns. In the present example, is association of interest is between developing lung cancer and exposure to the fungicide. The test is independent of the numbers of mice allocated to exposure or not and the numbers of mice that eventually develop tumors or not . The significance level of the test should only reflect the "inside" counts of this table and not these marginal total.