" Exercise 11.2 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 P Lutman, Rothamsted Research. Version 1, 3/05/2015 Set working directory - use setwd() function or from Session menu in RStudio e.g. SET [WORKINGDIRECTORY=d:/stats4biol/data'] " " Read data from ascii file " FILEREAD [NAME='DENSITY.DAT'; SKIP=1] ID,Block,Plot,B,C,Grain; FGROUPS=n,y,y,n,n,n " Get factor versions of B and C variates " GROUP B; FACTOR=Brate GROUP C; FACTOR=Crate " Get table of counts for factor combinations " TABULATE [PRINT=count; CLASS=Brate,Crate] " Fit intra-block model with Brate before Crate, using GenStat regression " MODEL Grain FIT [PRINT=model,summary,accumulated; FPROB=yes] Block+Brate*Crate " Check standardized residuals (called deviance residuals here)" " Default set of plots " RCHECK [RMETHOD=deviance] " Check absolute residual plot " RCHECK [RMETHOD=deviance] absresiduals; XMETHOD=fittedvalues " Fit intra-block model with Brate before Crate, using GenStat regression " MODEL Grain FIT [PRINT=model,summary,accumulated; FPROB=yes] Block+Crate*Brate " Predictions with SE " PREDICT [PREDICT=Tpred; SE=Tse] Brate,Crate PRINT Tpred,Tse; DEC=3,4 " Extract predictions " VTABLE Tpred; VARIATE=Vpred; CLASS=!P(fB,fC) VTABLE Tse; VARIATE=Vse " Get rid of missing combinations " SUBSET [CONDITION=Vpred.ne.c('*')] Vpred,Vse,fB,fC " Plot predictions " TRELLIS [GROUP=fC; KEY=0; TITLE='Grain yield predictions grouped by chickweed rate'; \ YTITLE='Prediction'; XTITLE='Barley rate'] Vpred+(0,0,-1,1)*Vse; fB; method=point,line,point,point " End of file "