# Code to illustrate inconsistency between AIC and summary output library(metafor) # setwd("c:\\My Documents\\Consulting\\SC&IT\\Hasintha Wijesekara\\data") #--------------------------------------------------------------------------------------------- # Data management section data0=read.table("Final final data set_Hasintha.txt",header=T,sep="\t",row.names = NULL ) head(data0) names(data0) data0=escalc(measure="MD",m1i=treat,sd1i=sdt,n1i=nt, m2i=control,sd2i=sdc,n2i=nc,vtype="HO", append=T,data=data0) # Remove 1 extreme observation data1=subset(data0,Citation!="Pérez-de-Mora et al., 2006") nrow(data1) # Remove records with missing values for random effects - metafor fails to execute otherwise data2=subset(data1,!is.na(data1$rate) & !is.na(data1$years)) nrow(data2) nrow(na.omit(data2[,-14])) # removing clay variable too # Base model f1=rma.mv(yi,vi,mods = ~rate + years + depth.mid , random = ~ 1 | Citation/soil/rate/years, data=data2,method="ML",na.exclude=T) summary(f1) # Add problem variable f2=rma.mv(yi,vi,mods = ~rate + years + depth.mid + biosolid.type, random = ~ 1 | Citation/soil/rate/years, data=data2,method="ML",na.exclude=T) summary(f2) AIC(f1,f2) # Inconsistency is that based on AIC being much lower model 2 with the addition of the new variable biosolid.type # is a much better model and with a 200 reduction in AIC it should be a very significant variable. # But in the summary output the two levels for biosolid.type are not very different to each other nor are they # significantly different to the reference category table(data2$biosolid.type) # So AIC says biosolid.type is an important variable, the summary table says it is not. # They should be in agreement, so what is going on? # Am I missing something? # Thanks, # Kim