### Code for AIC Multi-model analysis - Run an all model subsets analysis with multi-model inference ### import the data datum=read.csv(file.choose()) head(datum) ### Multi-model inference uses the MuMIn package library(MuMIn) ### Run Analysis # First generate your global model # if you have a lot of parameters, the 'dot' comes in very handy results=glm(Present~.,data=datum,family=binomial) ### '.' means include all variables in datum summary(results) ### unfortunately, we got too many variables, 'Pbird' was just used in creating data results=glm(Present~.-Pbird,data=datum,family=binomial) ### eliminate 'Pbird' summary(results) ### run an all subsets analysis using 'dredge' help(dredge) results=glm(Present~.,data=datum,family=binomial,na.action=na.fail) dd=dredge(results) ### only argument needed is the global model dd ### provides an AIC table ### What if you don't want all the models? ### spit out results to file! ### Be sure to change the directory, or include path in file name! ### write.table(dd,file="results.txt") ### load package 'arm' and include argument extra=se.coef in dredge to get standard errors ### run multi-model inference using model.avg and get.models help(get.models) help(model.avg) test=model.avg(get.models(dd,subset=TRUE)) ### Subset argument limits models included in analysis by AIC summary(test) importance(test)