Search this site

Just a note

t-tests & confidence limits

# input data y1=c(45,87,123,120,70) y2=c(51,71,42,37,51,78,51,49,56,47,58)

# log10 transform y1=log10(y1) # assume y is +ve y2=log10(y2) # EQ var t-test of diff between means n1=length(y1) # assume no missing points n2=length(y2) v1=var(y1) # assume no missing points v2=var(y2) df1=n1-1 # find their degrees of freedom df2=n2-1 D=0 # true difference assumed by H0 d=mean(y1)-mean(y2) # observed difference # estimate standard error of d se=sqrt((v1*df1+v2*df2)/(df1+df2)*(n1+n2)/(n1*n2)) t=(d-D)/se # observed t-statistic p=pt(t,df1+df2) # test t p=.5-abs(p-.5) # when p > 0.5 then p = 1-p p*2 # 2-tailed P-value # 95% confidence limits t=qt(0.05/2,df1+df2) # note t is -ve CL=d+t*se # lower limit CU=d-t*se # upper limit 10^d # ratio (detransformed treat effect) 10^CL # lower 95% limit to ratio 10^CU # upper 95% limit to ratio

Except where otherwise specified, all text and images on this page are copyright InfluentialPoints, all rights reserved. Images not copyright InfluentialPoints credit their source on web-pages attached via hypertext links from those images.