" Exercise 2.5
Statistical Methods in Biology: Design and Analysis of Experiments and Regression
by S.J. Welham, S.A. Gezan, S.J. Clark & A. Mead (2014)
Chapman & Hall/CRC Press, Boca Raton, Florida. ISBN: 978-1-4398-0878-8
Data from H.-C. Jing & K. Hammond-Kosack, Rothamsted Research
Version 1, 16/09/2014 "
" Set working directory - change to location of your data file "
\SET [WORKINGDIRECTORY='d:/stats4biol/data/']
" Read data from working directory "
FILEREAD [NAME='TRITICUM.DAT'; IMETHOD=read] FGROUPS=no
" Plot data "
DGRAPH Y=Weight; X=Length
" Sample statistics "
DESCRIBE [SELECTION=mean,var] DATA=Weight,Length
PRINT STRUCTURE=COV(Weight;Length)
" Correlation coefficient & test "
FCORRELATION [PRINT=correlation,test] DATA=Weight,Length
" Rest of file verifies calculations "
" Verify calculation of sample variances and covariance "
CALCULATE N = NVAL(Weight)
CALCULATE DevWt = Weight-MEAN(Weight)
CALCULATE DevLn = Length-MEAN(Length)
CALCULATE VarWt = SUM(DevWt*DevWt)/(N-1)
CALCULATE VarLn = SUM(DevLn*DevLn)/(N-1)
CALCULATE Cov = SUM(DevWt*DevLn)/(N-1)
PRINT VarWt, VarLn, Cov; DEC=4
" Calculation of correlation coefficient "
CALCULATE Corr = Cov/sqrt(VarWt*VarLn)
PRINT Corr; DEC=3
" Calculate t statistic "
CALCULATE t = Corr*sqrt((N-2)/(1-Corr**2))
PRINT t; DEC=3
" Get 5% critical value for two-sided test
= 97.5th quantile of t distribution with 10 df "
CALCULATE critical = EDT(0.975;N-2)
PRINT critical; DEC=3
" Get observed significance level for test
= proportion of t distribution with 10 df > abs(t) or < -abs(t) "
CALCULATE P = 2*CUT(ABS(t);n[1]+n[2]-2)
PRINT P; DEC=4
" End of File "