Dear all

I'm a beginner in R and I'm trying to get the final model after I run the
dredge function for 10 times (with a loop):

###Building the Model
Coy.glm0<-glm(pa ~  shrub + snowdep + tree + bio5 + bio6 + bio12 +
log(human+1), data=Coy.pa, family=binomial)
summary(Coy.glm0)

install.packages('MuMIn')
library(MuMIn)
Coy.dredge<-dredge(Coy.glm0)
head(Coy.dredge) ######################Look in which colum is AIC
###Building a simulation
Coy.models<-Coy.dredge[1,c(1:13)]
Coy.models


###Turn a loop who will create 10 models
run=1
while(run<11) #<11 means 10 models.
{
  Coy.abs$Long<-runif(300,498,2579440)
  Coy.abs$Lat<-runif(300,-51483,1377669)
  Coy.pa<-rbind(Coy.train, Coy.abs)    ####???? train ou prSS
  Coy.ppp<-ppp(Coy.pa$Long,Coy.pa$Lat, window=win, unitname="meters")
  Coy.pa$snowdep<-snowdepz.im[Coy.ppp, drop=F]
  Coy.pa$tree<-treez.im[Coy.ppp, drop=F]
  Coy.pa$bio5<-bio5z.im[Coy.ppp, drop=F]
  Coy.pa$bio6<-bio6z.im[Coy.ppp, drop=F]
  Coy.pa$bio12<-bio12z.im[Coy.ppp, drop=F]
  Coy.pa$human<-humanz.im[Coy.ppp, drop=F]
  Coy.pa$shrub<-shrub.im[Coy.ppp, drop=F]

  Coy.glm0<-glm(pa ~ shrub + snowdep + tree + bio5 +  bio6 + bio12+
log(human+1), data=Coy.pa, family=binomial)
  Coy.dredge<-dredge(Coy.glm0)
  Coy.models<-rbind(Coy.models, Coy.dredge[1,c(1:13)])
  run=run+1
}

I do get a best model for each run which I then hand pick and add to a
table. The problem is that I have 11 models now in this table and I want
their average to get the final model. I don't know how to do it from the
table (as the model.avg() will tell me I only have one model in the table,
because it's not recognizing the different rows as different models), but
on the other hand there must be a way to do it directly in the loop, only
I'm not sure at what point of the script I should be asking for it and how
the code should be written.

I would very much appreciate any help you can give me.

Thank you.

Cat

	[[alternative HTML version deleted]]

