#Biostatistics 402 #GLM F-TEST OF FM VS RM K=read.table("KNNLCh9SurgicalUnit.txt") K attach(K) options(digits=6) #FITTING THE FULL LINEAR MODEL FM=lm(Y~X1+X2+X3+X4+X5+factor(X6)) #FITTING A REDUCED LINEAR MODEL RM=lm(Y~X1+X2+X3+X5) #COMPARING MODELS anova(FM) anova(RM) #DEGREES OF FREEDOM n=length(Y) n dfF = summary.lm(FM)$df[2] dfF dfR = summary.lm(RM)$df[2] dfR #SUMS OF SQUARES ERROR SSEF = summary(FM)$sigma^2*summary(FM)$df[2] SSEF SSER = summary(RM)$sigma^2*summary(RM)$df[2] SSER #GLM TEST F-STATISTIC F=((SSER-SSEF)/(dfR-dfF))/(SSEF/dfF) F #ANOVA GLM F-TEST anova(RM,FM)