" Exercise 13.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 R. Harrington & C. Shortall, Rothamsted Research
Version 1, 01/01/2016 "
" Set working directory - change to location of your data file "
\SET [WORKINGDIRECTORY='d:/stats4biol/data/']
" Read data from working directory "
FILEREAD [NAME='HEREFORD.DAT'; IMETHOD=read] FGROUPS=no
" Analysis on without transformation "
" Plot data "
DGRAPH Y=WetWeight; X=Year
" Fit SLR "
MODEL Y=WetWeight
FIT [FPROBABILITY=yes; TPROBABILITY=yes] Year
" Save fitted values and standardized residuals "
RKEEP FITTEDVALUES=fval1; RESIDUALS=res1
" Residual plots based on standardized residuals "
DRESIDUALS [RESIDUALS=res1; FITTEDVALUES=fval1] METHOD=fittedvalues,normal,histogram,absresidual
" Plot fitted model "
RGRAPH [CIPLOT=yes]
" Analysis on with log-transformation "
" Transform the data to logs with offset of 0.5 (as in Exercise 12.2) "
CALCULATE logWt=LOG10(WetWeight+0.5)
" Plot data "
DGRAPH Y=logWt; X=Year
" Fit SLR "
MODEL Y=logWt
FIT [FPROBABILITY=yes; TPROBABILITY=yes] Year
" Save fitted values and standardized residuals "
RKEEP FITTEDVALUES=fval2; RESIDUALS=res2
" Residual plots based on standardized residuals "
DRESIDUALS [RESIDUALS=res2; FITTEDVALUES=fval2] METHOD=fittedvalues,normal,histogram,absresidual
" Plot fitted model "
RGRAPH [CIPLOT=yes]
" Investigate temporal correlation on log scale "
" Index plot "
PEN NUMBER=2; METHOD=line; COLOUR='black'; SYMBOLS=2
DGRAPH [TITLE=''] res2; Year; PEN=2
" Plot each residual against residual for previous year "
CALCULATE prevres=SHIFT(res2;1)
PEN NUMBER=2; METHOD=line; COLOUR='black'; SYMBOLS=0
DGRAPH [TITLE='Residual vs previous residual'] Y=res2; X=prevres
DGRAPH [SCREEN=keep; KEYWINDOW=0] Y=!(-5,5),!(0,0); X=!(0,0),!(-5,5); PEN=2
" Calculate correlation between residuals and previous residuals "
FCORRELATION [PRINT=correlation,test] DATA=res2,prevres
" Fit model with auto-regressive correlation between adjcent deviations "
GROUP Year; fYear
VCOMP [FIXED=Year; CAD=no] fYear
VSTRUCTURE [TERM=fYear] FACTOR=fYear; MODEL=AR
REML logWt
VDIS [PRINT=effects]
" End of File "