" Exercise 5.4 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 J. Baverstock, Rothamsted Research Version 1, 20/08/2014 " " Set working directory - change to location of your data file " \set [workingdirectory='d:/stats4biol/data/'] " Read data from working directory " FILEREAD [NAME='FUNGUS.DAT'; IMETHOD=read] FGROUPS=no,yes,no " Reorder levels of factor Treatment so that Control is the 3rd level " FACAMEND FACTOR=Fungus; NEWLEVELS=!(1,3,2) " Bartlett's test " VHOMOGENEITY [PRINT=test,variance; GROUPS=Fungus] DATA=Nymphs " Verify calculation " SCALAR N; VALUE=NVAL(Nymphs) SCALAR t; VALUE=NLEVELS(Fungus) " Get sample variances and replication " TABULATE [CLASSIFICATION=Fungus; COUNT=Tc] Nymphs; VARIANCE=Tvar PRINT Tc,Tvar; DECIMALS=0,2 VTABLE Tvar,Tc; VARIATE=Vvar,Vc " Get pooled estimate of variance " CALCULATE Pooled = SUM((Vc-1)*Vvar)/SUM(Vc-1) PRINT Pooled; DECIMALS=2 " Calculate scalar for Bartlett statistic " CALCULATE c = (SUM(1/(Vc-1))-1/(N-t))/(3*(t-1)) PRINT c; DECIMALS=3 " Calculate test statistic " CALCULATE X2 = ((N-t)*log(Pooled)-SUM((Vc-1)*log(Vvar)))/(1+c) PRINT X2; DECIMALS=3 " Get 95th percentile of Chisquared distribution on 2 df " PRINT EDCHI(0.95;2); DECIMALS=3 " Get observed significance level " PRINT CUCHI(X2;2); DECIMALS=3 " End of File "