To calculate the degrees of freedom for a correlation, you have
to subtract 2 from the total number of pairs of observations. If we
denote degrees of freedom by df, and the total number of pairs of
observations by N, then:
Degrees of freedom, df=N-2.
For instance, if you observed height and weight in 100 subjects,
you have 100 pairs of observations since each observation of height
and weight constitutes one pair. If you want to calcualte the
correlation for these two variables (height and weight), your
degrees of freedom would be calculated as follows:
N=100
df=N-2
Therefore, df=100-2=98
The degrees of freedom are a function of the parameters; you
subtract the amount of parameters free to vary from the n to get
the df, so logically in a correlation we should subtract 2 from n,
as we are looking at a correlation between 2 variables.