> #7.5 Cordial Drink Preference Example > x<-c(5,10,11,10,4) > > #Find mean to work out expected preferences from discrete uniform distribution > mean(x) [1] 8 > expected<-rep(sum(x)/length(x),length(x)) > tab<-cbind(x,expected) > colnames(tab)<-c("Observed","Expected") > tab Observed Expected [1,] 5 8 [2,] 10 8 [3,] 11 8 [4,] 10 8 [5,] 4 8 > > #gof stuff > GOF(tab) $AndersonDarling [1] 0.8854167 $Vr [1] -0.2236068 -2.2677868 -0.1118034 -0.2112886 $partition df SS pvalue Location 1 0.05000000 0.8230633 Dispersion 1 5.14285714 0.0233422 Skewness 1 0.01250000 0.9109793 Kurtosis 1 0.04464286 0.8326621 Total 4 5.25000000 0.2625941 > > #residual analysis > Vr<-GOF(tab)$Vr > residual<-sum(Vr^2)-Vr[2]^2 > residual [1] 0.1071429 > 1-pchisq(residual,3) [1] 0.9909667 >