#Doughnut example: Extra Residual Sums of Squares #read in the data don.dat=read.table("...\\doughnut.txt",header=TRUE) #attach the data set so I can use variable names from here on attach(don.dat) #reading in the RSS function source("...\\RSS.r") #this function calculates residuals sums of squares for #a given data set and desired group(s) #to call this function you need to specify three things #1: "data": the values for your response (in this case, called "absorbed") #2: "group": group identification (in this case called "fat") #3: "subset": which groups should be considered. For example, if you wanted the RSS for group 1, you would set subset=1. If you wanted to compute the RSS for all groups assuming al means are equal, you would set subset=1:4. If you wanted the RSS for groups 1 and 4 (assume 1 and 4 have the same mean), you would set subset=c(1,4) #examples #compute RSS for the reduced model: all means are equal RSS(data=absorbed,group=fat,subset=1:4) #compute RSS for the full model: all means are different RSS(data=absorbed,group=fat,subset=1)+RSS(data=absorbed,group=fat,subset=2)+RSS(data=absorbed,group=fat,subset=3)+RSS(data=absorbed,group=fat,subset=4) #compute RSS for the reduced model: group 1 and 3 have the same mean: RSS(data=absorbed,group=fat,subset=c(1,3))+RSS(data=absorbed,group=fat,subset=2)+RSS(data=absorbed,group=fat,subset=4)