##### Code for Marginal Sum of Squares test (also called lack of fit test) #### Note this code assumes you have already imported data and created # a regression object and an ANOVA object ###Importing data #datum=read.csv(file.choose()) #head(datum) ### Run a regression - treat Protein as continuous #results=lm(Mass~Protein) #Protein is continuous #summary(results) ### Run an ANOVA - treat Protein as categorical #results2=lm(Mass~as.factor(Protein),data=datum) ### use the as.factor function to get R to treat 'Protein' as continuous #summary(results2) ### Conduct the f-drop test anova(results,result2) ### the two models you want to compare are included as arguments ### order doesn't usually matter, but it's best to put the more complicated ### model first for those few cases where it does ### ### Note that the two models can't have the same number of parameters ### A significant p-value means the more complex model is a ### significant improvement in fit ### A non-significant p-value means the simpler model is adequate ### Note that RSS (which is the same thing as SSE) is always lower ### in the more complex model