Skip to content

Instantly share code, notes, and snippets.

@IronistM
Created November 11, 2013 10:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IronistM/7411117 to your computer and use it in GitHub Desktop.
Save IronistM/7411117 to your computer and use it in GitHub Desktop.
ANOVA<-function(fit1,fit2){
temp <- anova(fit2,fit1 )
fin.aov <- anova(fit1)
reg <- temp[2,2:6]
rownames(reg) <- "Regression"
reg[1,1:2] <- reg[1,2:3]
reg[1,3] <- reg[1,2]/reg[1,1]
colnames(reg) <- colnames(fin.aov)
res <- fin.aov[tail(nrow(fin.aov),1),]
tot <- cbind(reg[1,1:2]+res[1,1:2],NA,NA,NA)
rownames(tot) <- "Total"
colnames(tot) <- colnames(reg)
rbind(reg,res,tot)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment