Permalink
Browse files

update to AIC method to include model names

  • Loading branch information...
liamrevell committed Oct 29, 2017
1 parent f8f6b89 commit f3f3d91d8031e1d83456583c7f46f60d922c6ec8
Showing with 9 additions and 4 deletions.
  1. +9 −4 R/ratebytree.R
View
@@ -698,12 +698,17 @@ AIC.ratebytree<-function(object,...,k=2){
aic<-data.frame(AIC=c(k*object$common.rate.model$k-2*object$common.rate.model$logL,
k*object$multi.rate.model$k-2*object$multi.rate.model$logL),
df=c(object$common.rate.model$k,object$multi.rate.model$k))
model.names<-if(is.null(object$model)) 1 else object$model
addtl.obj<-list(...)
if(length(addtl.obj)>0){
for(i in 1:length(addtl.obj)) aic<-rbind(aic,
c(k*addtl.obj[[i]]$multi.rate.model$k-2*addtl.obj[[i]]$multi.rate.model$logL,
addtl.obj[[i]]$multi.rate.model$k))
rownames(aic)<-c("common-rate",paste("multi-rate:",1:(length(addtl.obj)+1),sep=""))
for(i in 1:length(addtl.obj)){
aic<-rbind(aic,c(k*addtl.obj[[i]]$multi.rate.model$k-
2*addtl.obj[[i]]$multi.rate.model$logL,
addtl.obj[[i]]$multi.rate.model$k))
model.names<-c(model.names,
if(is.null(addtl.obj[[i]]$model)) 1+i else addtl.obj[[i]]$model)
}
rownames(aic)<-c("common-rate",paste("multi-rate:",model.names,sep=""))
} else rownames(aic)<-c("common-rate","multi-rate")
aic
}

0 comments on commit f3f3d91

Please sign in to comment.