########################################################## # df is a function for calculating the degree of freedom # # for the 2 independent sample t-test (Formula 7.1 in # # the textbook). # # Needs the standard deviation in both samples, as well # # as the 2 sample sizes. # ########################################################## df = function(sd1,sd2,n1,n2){ (sd1^2/n1+sd2^2/n2)^2/(sd1^4/(n1^2*(n1-1))+sd2^4/(n2^2*(n2-1))) } # example of use: if standard deviations are sd1=1.7 and sd2=2.3 # and sample sizes are n1=8 and n2=10, then do # df(1.7,2.3,8,10)