# # Epage 137 # # Written by: # -- # John L. Weatherwax 2009-04-21 # # email: wax@alum.mit.edu # # Please send comments and especially bug reports to the # above email address. # #----- # version$language == "R" for R version$language == NULL for SPlus if(is.null(version$language) == FALSE){ require(alr3) }else{ library(alr3) } if(is.null(version$language) == FALSE) data(prodscore) attach(prodscore) countyFactor <- factor( County, ordered=FALSE ) yearFactor <- factor( Year, ordered=FALSE ) mNH <- lm( Value ~ countyFactor + yearFactor ) # the null hypothesis summary(mNH) mAH <- lm( Value ~ countyFactor + yearFactor + P ) # the alternative hypothesis summary(mAH) anova(mNH,mAH) # Now are the other factor variables important? # mCP <- lm( Value ~ countyFactor + P ) mYP <- lm( Value ~ yearFactor + P ) mP <- lm( Value ~ P ) anova(mCP,mAH) # does the year factor provide information ... yes anova(mYP,mAH) # does the county factor provide information ... yes anova(mP,mAH) # does the country+year factors provide information ... yes