Re: model selection and averaging in unmarked?

3,465 views
Skip to first unread message

Richard Chandler

unread,
Oct 11, 2010, 7:59:41 AM10/11/10
to Matthew Giovanni, unma...@googlegroups.com
Hi Matt,

unmarked returns AIC rather than AICc because it is not clear, to me
at least, what the effective sample size is for these models. I think
this issue was discussed in a previous thread and in the MacKenzie et
al 2005 book.

As for model averaging, see help(fitList). Basically, you put your
models in a fitList object, and then you use predict:

fmList <- fitList(m1, m2, m3, etc...) # put models in a fitList object
predict(fmList, type="state") # expected values for
original data. or,
predict(fmList, type="state", newdata = somenewdata)

This will give you model-averaged predictions and SEs. We have
intentionally not provided capabilities for model-averaging beta
coefficients or variance-covariance matrices.

Richard

On Mon, Oct 11, 2010 at 3:37 AM, Matthew Giovanni
<matthew...@gmail.com> wrote:
> Hi Richard-
>
> I'm wondering if unmarked has functions or options to calculate and return
> AICc values from a fitList object, rather than just AIC.  Also, I was
> reading the users manual and there is some mention of calculating
> model-averaged coeffs and preds in unmarked, but I haven't been able to
> figure out an efficient way of doing so.  Any insights or suggestions?  Here
> are example data and R files if that helps.  Thanks for your help and
> expertise, as always.
>
> Matt
> ____________________________________
> Matt Giovanni
> Postdoctoral Visiting Research Fellow
> Canadian Wildlife Service
> 2365 Albert St., Room 300
> Regina, SK S4P 4K1
> 306-780-6121 work
> 402-617-3764 mobile
> Research website:
> http://sites.google.com/site/matthewgiovanni/
>

Giancarlo Sadoti

unread,
Nov 13, 2010, 11:05:20 PM11/13/10
to unmarked
Hi Richard,

I'm really glad you incorporated this method for generating
predictions from model-averaged parameter estimates via the use of a
fitList object. I noticed that you also added the ability to generate
predictions from fitLists of multiple colext models (which is
great!).

A question: if using a new dataset to generate predictions, must this
dataset have the same sampling structure (i.e., same # of seasons and
surveys) as the data from which the fitList was originally built? I
was unable to get it to work with a new dataset having the same number
of sites, seasons, and site/survey covariates, but fewer surveys per
site/season. It may be something I did wrong, but if not, have you
incorporated any other methods for setting ('fixing') covariate
coefficients in an occu or colext model? I had asked earlier about
the ability to do this for using model-averaged detection parameter
estimates prior to building occu (or colext) models and you thought
you might include this ability in future releases.

Best,

Giancarlo


On Oct 11, 4:59 am, Richard Chandler <richard.chandl...@gmail.com>
wrote:
> Hi Matt,
>
> unmarked returns AIC rather than AICc because it is not clear, to me
> at least, what the effective sample size is for these models. I think
> this issue was discussed in a previous thread and in the MacKenzie et
> al 2005 book.
>
> As formodelaveraging, see help(fitList). Basically, you put your
> models in a fitList object, and then you use predict:
>
> fmList <- fitList(m1, m2, m3, etc...)  # put models in a fitList object
> predict(fmList, type="state")            # expected values for
> original data. or,
> predict(fmList, type="state", newdata = somenewdata)
>
> This will give youmodel-averaged predictions and SEs. We have
> intentionally not provided capabilities formodel-averagingbeta
> coefficients or variance-covariance matrices.
>
> Richard
>
> On Mon, Oct 11, 2010 at 3:37 AM, Matthew Giovanni
>

Andy Royle

unread,
Nov 15, 2010, 8:40:17 AM11/15/10
to unma...@googlegroups.com

hi Giancarlo -- I wish I could help you with this one but I don't know much about the prediction capabilities and functions so this will have to wait for Richard if/when he has time to dig into it. He's out for awhile with a new baby in the family that just arrived on Saturday!
regards
andy

 

-----unma...@googlegroups.com wrote: -----

To: unmarked <unma...@googlegroups.com>
From: Giancarlo Sadoti <gcsa...@gmail.com>
Sent by: unma...@googlegroups.com
Date: 11/13/2010 11:05PM
Subject: [unmarked] Re: model selection and averaging in unmarked?

Giancarlo Sadoti

unread,
Nov 15, 2010, 8:20:23 PM11/15/10
to unmarked
Thanks Andy and congrats to Richard! I have a 2 month old, so I
completely understand. Giancarlo

On Nov 15, 6:40 am, Andy Royle <aro...@usgs.gov> wrote:
> hi Giancarlo -- I wish I could help you with this one but I don't know much about the prediction capabilities and functions so this will have to wait for Richard if/when he has time to dig into it. He's out for awhile with a new baby in the family that just arrived on Saturday!
>
> regards
>
> andy
>
>
>  
>
>
>
> -----unma...@googlegroups.com wrote: -----To: unmarked <unma...@googlegroups.com>
> From: Giancarlo Sadoti <gcsa...@gmail.com>
> Sent by: unma...@googlegroups.com
> Date: 11/13/2010 11:05PM
> Subject: [unmarked] Re: model selection and averaging in unmarked?Hi Richard,

Richard Chandler

unread,
Nov 16, 2010, 8:46:32 AM11/16/10
to unma...@googlegroups.com
Hi Giancarlo,

The newdata object needs to be a data.frame with column names matching the covariate names used in the fitted models. This is the same as when using predict on a single model. You don't need to think about the number of seasons or sites. Each row is a combination of the covariates for which you want some prediction. See the example below, where model-averaged estimates of psi are returned for various values of x1 while holding x2 constant. Note that this is different from "fixing" parameters during the estimation process.

Kind regards,
Richard



library(unmarked)

# fake data
y <- matrix(c(
  1,0,1, 0,1,1, 0,0,0,
  1,1,1, 0,0,0, 0,0,0,
  0,0,0, 0,0,0, 1,1,0,
  0,0,0, 0,0,0, 0,0,0),
  nrow=4, ncol=9, byrow=TRUE)

x1 <- 1:4
x2 <- -(1:4)

umf <- unmarkedMultFrame(y=y, siteCovs=data.frame(x1=x1, x2=x2), numPrimary=3)


# Three models
m1 <- colext(~1, ~1, ~1, ~1, umf)
m2 <- colext(~x1, ~1, ~1, ~1, umf)
m3 <- colext(~x2, ~1, ~1, ~1, umf)

# Organize them
fms <- fitList(m1=m1, m2=m2, m3=m3)
modSel(fms)

# Model-averaged estimates of psi
newdata <- data.frame(x1=seq(1, 4, length=10), x2=-2)
Epsi <- predict(fms, type="psi", newdata=newdata, appendData=TRUE)
Epsi

Pablo

unread,
May 29, 2013, 6:47:08 PM5/29/13
to unma...@googlegroups.com, Matthew Giovanni
Dear Marc,

I am learning how to use distamp and occu and for my project I need to average models under 2 AIC and AICc points. I need to obtain coefficients of the averaged models, in occu I was able to obtain those with the model.avg(ms1,subset=delta < 2) function ,

 but in distsamp I receive this message error

 model.avg(fms2,subset=delta < 2)
Error in model.avg.default(fms2, subset = delta < 2) : 
  object 'delta' not found

I been trying to find out what is my mistake or if possible to average models for distsamp function with no success.
I will appreciate any help that you can provide.

Sincerely ,

Pablo Oleiro

Chris Sutherland

unread,
May 29, 2013, 10:59:24 PM5/29/13
to unma...@googlegroups.com, Matthew Giovanni

Hi Pablo

 

It would be helpful to see the code you used to run the models across which you are trying to average.

 

Thanks

 

Chris

 

From: unma...@googlegroups.com [mailto:unma...@googlegroups.com] On Behalf Of Pablo
Sent: Wednesday, May 29, 2013 6:47 PM
To: unma...@googlegroups.com
Cc: Matthew Giovanni
Subject: [unmarked] Re: model selection and averaging in unmarked?

 

Dear Marc,

--
You received this message because you are subscribed to the Google Groups "unmarked" group.
To unsubscribe from this group and stop receiving emails from it, send an email to unmarked+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Pablo

unread,
May 30, 2013, 11:18:16 AM5/30/13
to unma...@googlegroups.com, Matthew Giovanni

Chris,

These are a sample of the models that I am using,  

> Habitat<-distsamp(~1~AgroFo+Wetland+SecVeg,keyfun="hazard", unitsOut="ha", output="density",data=umf)   
> Hab_StdElev<-distsamp(~1~AgroFo+Wetland+SecVeg+StdElev,keyfun="hazard", unitsOut="ha", output="density",data=umf)

then I create a fitList

fms2<-fitList('StdElev'=StdElev,'Null_Null'=Null_Null,'Habitat'=Habitat,'Hab_StdElev'=Hab_StdElev,'Hab_PN'=Hab_PN,'PN_LNEdge'=PN_LNEdge,
+               'PN'=PN,'LNEdge'=LNEdge,'Hab_LNEdge'=Hab_LNEdge,'StdElev_PN'=StdElev_PN,'StdElev_LNEdge'=StdElev_LNEdge,'H_SEl_LEd'=H_SEl_LEd,'Global'=Global)

modSel(fms2)

The result from this is this table 

               nPars     AIC delta   AICwt cumltvWt
Habitat            6 1377.63  0.00 3.8e-01     0.38
Hab_StdElev        7 1378.98  1.35 1.9e-01     0.57
Hab_PN             7 1379.24  1.61 1.7e-01     0.74
Hab_LNEdge         7 1379.50  1.87 1.5e-01     0.89
H_SEl_LEd          8 1380.93  3.30 7.3e-02     0.96
Global             9 1382.47  4.84 3.4e-02     1.00
StdElev            4 1391.01 13.38 4.7e-04     1.00
StdElev_PN         5 1391.10 13.47 4.5e-04     1.00
StdElev_LNEdge     5 1391.23 13.60 4.2e-04     1.00
PN                 4 1396.54 18.91 3.0e-05     1.00
Null_Null          3 1398.19 20.56 1.3e-05     1.00
PN_LNEdge          5 1398.37 20.74 1.2e-05     1.00
LNEdge             5 1398.37 20.74 1.2e-05     1.00 

I try to use the command, but I get this error message.

 model.avg(fms2,subset=delta < 2)

Error in model.avg.default(fms2, subset = delta < 2) : 

  object 'delta' not found


Any input or help will be appreciated, thank you so much for taking a look to this issue.

Best,

Pablo

Richard Chandler

unread,
Jun 3, 2013, 10:13:55 AM6/3/13
to Unmarked package, marc.ma...@uqat.ca
Hi Pablo,

The model.avg() function is not part of unmarked. Are you using the package AICcmodavg? If so, perhaps Marc Mazerolle can help.

Richard

Marc.Ma...@uqat.ca

unread,
Jun 4, 2013, 8:21:46 AM6/4/13
to richard....@gmail.com, unma...@googlegroups.com
Pablo,

model.avg( ) is part of package MuMIn, you should ask the package maintainer for help on that function.

Otherwise, you might want to try modavg( ) in package AICcmodavg, for model averaging beta estimates, with something like this:

library(unmarked)
library(AICcmodavg)

data(linetran)
    
ltUMF <- with(linetran, {
  unmarkedFrameDS(y = cbind(dc1, dc2, dc3, dc4),
                  siteCovs = data.frame(Length, area, habitat),
                  dist.breaks = c(0, 5, 10, 15, 20),
                  tlength = linetran$Length * 1000, survey = "line", unitsIn = "m")
})

## Halfnormal. Covariates affecting both density and and detection.
fm2 <- distsamp(~area + habitat ~ habitat, ltUMF)
fm3 <- distsamp(~area + habitat ~ habitat, ltUMF, keyfun="hazard")

Cands <- list(fm1, fm2, fm3)
Modnames <- paste("mod", 1:length(Cands), sep = "")

modavg(Cands, Modnames, parm = "habitatB", parm.type = "lambda")

Best,

Marc

--
____________________________________
Marc J. Mazerolle
Centre d'étude de la forêt
Université du Québec en Abitibi-Témiscamingue
445 boulevard de l'Université
Rouyn-Noranda, Québec J9X 5E4, Canada
Tel: (819) 762-0971 ext. 2458
Email: marc.ma...@uqat.ca

De : Richard Chandler [richard....@gmail.com]
Date d'envoi : lundi 3 juin 2013 10:13
À : Unmarked package; Mazerolle, Marc
Objet : Re: [unmarked] Re: model selection and averaging in unmarked?

Chris Sutherland

unread,
Jun 4, 2013, 8:44:26 AM6/4/13
to unma...@googlegroups.com

Pablo,

 

I think this might just be a case of putting the right object into the mod.avg()function.

You have:

 

model.avg(fms2,subset=delta < 2)

 

Where fms2 is a fitList and not a modSel object so there is no delta to be used for the subsetting <- source of error. So try this out:

 

ms1 <- modSel(fms2)

model.avg(ms1,subset=delta < 2)

 

Sorry for delay in my response having asked to see a bit more. I hope that helps…?

Pablo

unread,
Jul 22, 2013, 6:04:27 PM7/22/13
to unma...@googlegroups.com
Hi Chris,

Thanks for the reply. I tried and still says that object delta is not found 


 ms1<-modSel(fms2)
> ms1
           nPars    AIC delta   AICwt cumltvWt
Habitat        7 458.11  0.00 0.51678     0.52
Hab_PN         8 459.99  1.87 0.20257     0.72
Hab_LNEdge     8 460.02  1.91 0.19918     0.92
Global         9 461.99  3.88 0.07444     0.99
PN             5 468.07  9.95 0.00356     1.00
PN_LNEdge      6 469.98 11.87 0.00137     1.00
LNEdge         6 469.98 11.87 0.00137     1.00
Null_Null      4 471.25 13.14 0.00072     1.00
> ms1<-modSel(fms2)
> model.avg(ms1,subset=delta<2)
Error in model.avg.default(ms1, subset = delta < 2) : 
  object 'delta' not found


Thanks for the help and sorry that I did not reply before I was busy and getting ready for fieldwork . If you have another idea that I can try please let me know.

Thanks,

Pablo

Richard Chandler

unread,
Jul 28, 2013, 7:59:49 AM7/28/13
to Unmarked package
Hi Pablo,

You could do something like:

ms1df <- as(ms1, "data.frame")
subset(ms1df, delta<2)

Richard

Pablo Oleiro

unread,
Aug 19, 2013, 3:57:10 PM8/19/13
to unma...@googlegroups.com
Hi Richard,

I tried your suggestion and get these 

 model                                           formula lam(AgroFo) SElam(AgroFo)  lam(Int)
2    Habitat ~Obs + Wind ~ Wetland + AgroFo + SecVeg + Wetland   0.6750684     0.2653434 -1.543562
3     Hab_PN      ~Obs + Wind ~ Wetland + AgroFo + SecVeg + PN   0.7593324     0.2690820 -1.295718
7 Hab_LNEdge  ~Obs + Wind ~ Wetland + AgroFo + SecVeg + LNEdge   0.7409290     0.2685012 -1.500183
  SElam(Int) lam(LNEdge) SElam(LNEdge)    lam(PN) SElam(PN) lam(SecVeg) SElam(SecVeg) lam(Wetland)
2  0.1608800          NA            NA         NA        NA   0.8380666     0.3485525     1.431327
3  0.2573567          NA            NA -0.2044303 0.1680027   0.9959054     0.3605524     1.405486
7  0.1644069 -0.04018447    0.03704068         NA        NA   0.9801160     0.3628843     1.413577
  SElam(Wetland) p(sigma(Intercept)) SEp(sigma(Intercept)) p(sigmaObsE) SEp(sigmaObsE) p(sigmaObsJ)
2      0.1880082            3.985389            0.09493167    0.1552567      0.1080814    0.1346002
3      0.1882181            3.983239            0.09454148    0.1667710      0.1084129    0.1478493
7      0.1875546            3.988795            0.09507646    0.1600893      0.1082677    0.1406727
  SEp(sigmaObsJ) p(sigmaObsP) SEp(sigmaObsP) p(sigmaWind) SEp(sigmaWind) Converge  CondNum negLogLike
2      0.1156136    0.2289370     0.09263715  -0.04876901     0.02897823        0 864.3129   489.0275
3      0.1162355    0.2366194     0.09242013  -0.05161521     0.02914716        0 928.8630   488.2564
7      0.1159805    0.2316956     0.09255071  -0.05204200     0.02920309        0 948.6319   488.4290
  nPars   n      AIC     delta     AICwt Rsq  cumltvWt
2     9 234 996.0549 0.0000000 0.3626489  NA 0.3626489
3    10 234 996.5129 0.4579434 0.2884332  NA 0.6510821
7    10 234 996.8579 0.8029949 0.2427271  NA 0.8938092

Which is a subset of the models under to AIC, however is not the average.
I tried to model.avg(subset(ms1df,delta<2)) to see if this work but it does not. The error message is 

Error in model.avg.default(subset(ms1df, delta < 2)) : 
  only one model supplied. Nothing to do

Once again I would appreciate any comments. 

Have a great week.

Pablo

Richard Chandler

unread,
Aug 19, 2013, 4:36:11 PM8/19/13
to Unmarked package
Hi Pablo,

model.avg() is not a function in unmarked so I'm afraid I can't help you. Perhaps someone else on this list is familiar with it.

Richard

Matthew Butler

unread,
Aug 19, 2013, 4:47:25 PM8/19/13
to unma...@googlegroups.com
Pablo,

Looking through this string it appears you used the fitlist in the model.avg function instead of a model selection table.

Maybe try the following instead.

>models=modSel(fms2)
>model.avg(models,subset=delta < 2)

Thanks,

Matthew Butler

Richard Schuster

unread,
Aug 19, 2013, 4:55:59 PM8/19/13
to unma...@googlegroups.com
Hi Pablo,

I was thinking the same as Matthew, but it looks like this is not working either (just tried with an example of my data).
It might be easiest to run a global model including all your covariates and then use dredge and model.avg:

modlst <- dredge(global.model)
model.avg(modlst.model, delta<2)


Cheers,
Richard

Am 19/08/2013 13:47, schrieb Matthew Butler:
Pablo,

Looking through this string it appears you used the fitlist in the model.avg function instead of a model selection table.

Maybe try the following instead.

>models=modSel(fms2)
>model.avg(models,subset=delta < 2)

Thanks,

Matthew Butler



On Monday, August 19, 2013 1:57:10 PM UTC-6, Pablo wrote:
Hi Richard,

I tried your suggestion and get theseᅵ

ᅵmodel ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ formula lam(AgroFo) SElam(AgroFo) ᅵlam(Int)
2 ᅵ ᅵHabitat ~Obs + Wind ~ Wetland + AgroFo + SecVeg + Wetland ᅵ 0.6750684 ᅵ ᅵ 0.2653434 -1.543562
3 ᅵ ᅵ Hab_PN ᅵ ᅵ ᅵ~Obs + Wind ~ Wetland + AgroFo + SecVeg + PN ᅵ 0.7593324 ᅵ ᅵ 0.2690820 -1.295718
7 Hab_LNEdge ᅵ~Obs + Wind ~ Wetland + AgroFo + SecVeg + LNEdge ᅵ 0.7409290 ᅵ ᅵ 0.2685012 -1.500183
ᅵ SElam(Int) lam(LNEdge) SElam(LNEdge) ᅵ ᅵlam(PN) SElam(PN) lam(SecVeg) SElam(SecVeg) lam(Wetland)
2 ᅵ0.1608800 ᅵ ᅵ ᅵ ᅵ ᅵNA ᅵ ᅵ ᅵ ᅵ ᅵ ᅵNA ᅵ ᅵ ᅵ ᅵ NA ᅵ ᅵ ᅵ ᅵNA ᅵ 0.8380666 ᅵ ᅵ 0.3485525 ᅵ ᅵ 1.431327
3 ᅵ0.2573567 ᅵ ᅵ ᅵ ᅵ ᅵNA ᅵ ᅵ ᅵ ᅵ ᅵ ᅵNA -0.2044303 0.1680027 ᅵ 0.9959054 ᅵ ᅵ 0.3605524 ᅵ ᅵ 1.405486
7 ᅵ0.1644069 -0.04018447 ᅵ ᅵ0.03704068 ᅵ ᅵ ᅵ ᅵ NA ᅵ ᅵ ᅵ ᅵNA ᅵ 0.9801160 ᅵ ᅵ 0.3628843 ᅵ ᅵ 1.413577
ᅵ SElam(Wetland) p(sigma(Intercept)) SEp(sigma(Intercept)) p(sigmaObsE) SEp(sigmaObsE) p(sigmaObsJ)
2 ᅵ ᅵ ᅵ0.1880082 ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ3.985389 ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ0.09493167 ᅵ ᅵ0.1552567 ᅵ ᅵ ᅵ0.1080814 ᅵ ᅵ0.1346002
3 ᅵ ᅵ ᅵ0.1882181 ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ3.983239 ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ0.09454148 ᅵ ᅵ0.1667710 ᅵ ᅵ ᅵ0.1084129 ᅵ ᅵ0.1478493
7 ᅵ ᅵ ᅵ0.1875546 ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ3.988795 ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ0.09507646 ᅵ ᅵ0.1600893 ᅵ ᅵ ᅵ0.1082677 ᅵ ᅵ0.1406727
ᅵ SEp(sigmaObsJ) p(sigmaObsP) SEp(sigmaObsP) p(sigmaWind) SEp(sigmaWind) Converge ᅵCondNum negLogLike
2 ᅵ ᅵ ᅵ0.1156136 ᅵ ᅵ0.2289370 ᅵ ᅵ 0.09263715 ᅵ-0.04876901 ᅵ ᅵ 0.02897823 ᅵ ᅵ ᅵ ᅵ0 864.3129 ᅵ 489.0275
3 ᅵ ᅵ ᅵ0.1162355 ᅵ ᅵ0.2366194 ᅵ ᅵ 0.09242013 ᅵ-0.05161521 ᅵ ᅵ 0.02914716 ᅵ ᅵ ᅵ ᅵ0 928.8630 ᅵ 488.2564
7 ᅵ ᅵ ᅵ0.1159805 ᅵ ᅵ0.2316956 ᅵ ᅵ 0.09255071 ᅵ-0.05204200 ᅵ ᅵ 0.02920309 ᅵ ᅵ ᅵ ᅵ0 948.6319 ᅵ 488.4290
ᅵ nPars ᅵ n ᅵ ᅵ ᅵAIC ᅵ ᅵ delta ᅵ ᅵ AICwt Rsq ᅵcumltvWt
2 ᅵ ᅵ 9 234 996.0549 0.0000000 0.3626489 ᅵNA 0.3626489
3 ᅵ ᅵ10 234 996.5129 0.4579434 0.2884332 ᅵNA 0.6510821
7 ᅵ ᅵ10 234 996.8579 0.8029949 0.2427271 ᅵNA 0.8938092

Which is a subset of the models under to AIC, however is not the average.
I tried toᅵmodel.avg(subset(ms1df,delta<2)) to see if this work but it does not. The error message isᅵ

Error in model.avg.default(subset(ms1df, delta < 2)) :ᅵ
ᅵ only one model supplied. Nothing to do

Once again I would appreciate any comments.ᅵ

Have a great week.

Pablo
On Sun, Jul 28, 2013 at 6:59 AM, Richard Chandler <richard....@gmail.com> wrote:
Hi Pablo,

You could do something like:

ms1df <- as(ms1, "data.frame")
subset(ms1df, delta<2)

Richard

On Mon, Jul 22, 2013 at 6:04 PM, Pablo <pcol...@gmail.com> wrote:
Hi Chris,

Thanks for the reply. I tried and still says that object delta is not foundᅵ


ᅵms1<-modSel(fms2)
> ms1
ᅵ ᅵ ᅵ ᅵ ᅵ ᅵnPars ᅵ ᅵAIC delta ᅵ AICwt cumltvWt
Habitat ᅵ ᅵ ᅵ ᅵ7 458.11 ᅵ0.00 0.51678 ᅵ ᅵ 0.52
Hab_PN ᅵ ᅵ ᅵ ᅵ 8 459.99 ᅵ1.87 0.20257 ᅵ ᅵ 0.72
Hab_LNEdge ᅵ ᅵ 8 460.02 ᅵ1.91 0.19918 ᅵ ᅵ 0.92
Global ᅵ ᅵ ᅵ ᅵ 9 461.99 ᅵ3.88 0.07444 ᅵ ᅵ 0.99
PN ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ 5 468.07 ᅵ9.95 0.00356 ᅵ ᅵ 1.00
PN_LNEdge ᅵ ᅵ ᅵ6 469.98 11.87 0.00137 ᅵ ᅵ 1.00
LNEdge ᅵ ᅵ ᅵ ᅵ 6 469.98 11.87 0.00137 ᅵ ᅵ 1.00
Null_Null ᅵ ᅵ ᅵ4 471.25 13.14 0.00072 ᅵ ᅵ 1.00
> ms1<-modSel(fms2)
> model.avg(ms1,subset=delta<2)
Error in model.avg.default(ms1, subset = delta < 2) :ᅵ
ᅵ object 'delta' not found


Thanks for the help and sorry that I did not reply before I was busy and getting ready for fieldwork . If you have another idea that I can try please let me know.

Thanks,

Pablo

On Tuesday, June 4, 2013 7:44:26 AM UTC-5, chrissuthy wrote:

Pablo,

ᅵ

I think this might just be a case of putting the right object into the mod.avg()function.

You have:

ᅵ

model.avg(fms2,subset=delta < 2)

ᅵ

Where fms2 is a fitList and not a modSel object so there is no delta to be used for the subsetting <- source of error. So try this out:

ᅵ

ms1 <- modSel(fms2)

model.avg(ms1,subset=delta < 2)

ᅵ

Sorry for delay in my response having asked to see a bit more. I hope that helps…?

ᅵ

Chris

ᅵ

ᅵ

From: unma...@googlegroups.com [mailto:unma...@googlegroups.com] On Behalf Of Pablo
Sent: Thursday, May 30, 2013 11:18 AM
To: unma...@googlegroups.com
Cc: 'Matthew Giovanni'
Subject: Re: [unmarked] Re: model selection and averaging in unmarked?

ᅵ


Chris,

ᅵ

These are a sample of the models that I am using, ᅵ

ᅵ

> Habitat<-distsamp(~1~AgroFo+Wetland+SecVeg,keyfun="hazard", unitsOut="ha", output="density",data=umf) ᅵᅵ

> Hab_StdElev<-distsamp(~1~AgroFo+Wetland+SecVeg+StdElev,keyfun="hazard", unitsOut="ha", output="density",data=umf)

ᅵ

then I create a fitList

ᅵ

fms2<-fitList('StdElev'=StdElev,'Null_Null'=Null_Null,'Habitat'=Habitat,'Hab_StdElev'=Hab_StdElev,'Hab_PN'=Hab_PN,'PN_LNEdge'=PN_LNEdge,

+ ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ 'PN'=PN,'LNEdge'=LNEdge,'Hab_LNEdge'=Hab_LNEdge,'StdElev_PN'=StdElev_PN,'StdElev_LNEdge'=StdElev_LNEdge,'H_SEl_LEd'=H_SEl_LEd,'Global'=Global)

ᅵ

modSel(fms2)

ᅵ

The result from this is this tableᅵ

ᅵ

ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ ᅵnPars ᅵ ᅵ AIC delta ᅵ AICwt cumltvWt

Habitat ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ6 1377.63 ᅵ0.00 3.8e-01 ᅵ ᅵ 0.38

Hab_StdElev ᅵ ᅵ ᅵ ᅵ7 1378.98 ᅵ1.35 1.9e-01 ᅵ ᅵ 0.57

Hab_PN ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ 7 1379.24 ᅵ1.61 1.7e-01 ᅵ ᅵ 0.74

Hab_LNEdge ᅵ ᅵ ᅵ ᅵ 7 1379.50 ᅵ1.87 1.5e-01 ᅵ ᅵ 0.89

H_SEl_LEd ᅵ ᅵ ᅵ ᅵ ᅵ8 1380.93 ᅵ3.30 7.3e-02 ᅵ ᅵ 0.96

Global ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ 9 1382.47 ᅵ4.84 3.4e-02 ᅵ ᅵ 1.00

StdElev ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ4 1391.01 13.38 4.7e-04 ᅵ ᅵ 1.00

StdElev_PN ᅵ ᅵ ᅵ ᅵ 5 1391.10 13.47 4.5e-04 ᅵ ᅵ 1.00

StdElev_LNEdge ᅵ ᅵ 5 1391.23 13.60 4.2e-04 ᅵ ᅵ 1.00

PN ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ 4 1396.54 18.91 3.0e-05 ᅵ ᅵ 1.00

Null_Null ᅵ ᅵ ᅵ ᅵ ᅵ3 1398.19 20.56 1.3e-05 ᅵ ᅵ 1.00

PN_LNEdge ᅵ ᅵ ᅵ ᅵ ᅵ5 1398.37 20.74 1.2e-05 ᅵ ᅵ 1.00

LNEdge ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ 5 1398.37 20.74 1.2e-05 ᅵ ᅵ 1.00ᅵ

ᅵ

I try to use the command, but I get this error message.

ᅵ

ᅵmodel.avg(fms2,subset=delta < 2)

Error in model.avg.default(fms2, subset = delta < 2) :ᅵ

ᅵ object 'delta' not found

ᅵ

Any input or help will be appreciated, thank you so much for taking a look to this issue.

Best,

Pablo

ᅵ

ᅵ

ᅵ


On Wednesday, May 29, 2013 9:59:24 PM UTC-5, chrissuthy wrote:

Hi Pablo

ᅵ

It would be helpful to see the code you used to run the models across which you are trying to average.

ᅵ

Thanks

ᅵ

Chris

ᅵ

From: unma...@googlegroups.com [mailto:unma...@googlegroups.com] On Behalf Of Pablo
Sent: Wednesday, May 29, 2013 6:47 PM
To: unma...@googlegroups.com
Cc: Matthew Giovanni
Subject: [unmarked] Re: model selection and averaging in unmarked?

ᅵ

Dear Marc,

ᅵ

I am learning how to use distamp and occu and for my project I need to average models under 2 AIC and AICc points. I need to obtain coefficients of the averaged models, in occu I was able to obtain those with theᅵmodel.avg(ms1,subset=delta < 2) function ,

ᅵ

ᅵbut in distsamp I receive this message error

ᅵ

ᅵmodel.avg(fms2,subset=delta < 2)

Error in model.avg.default(fms2, subset = delta < 2) :ᅵ

ᅵ object 'delta' not found

ᅵ

I been trying to find out what is my mistake or if possible to average models for distsamp function with no success.

I will appreciate any help that you can provide.

ᅵ

Sincerely ,

ᅵ

Pablo Oleiro


On Monday, October 11, 2010 6:59:41 AM UTC-5, Richard Chandler wrote:

Hi Matt,

unmarked returns AIC rather than AICc because it is not clear, to me
at least, what the effective sample size is for these models. I think
this issue was discussed in a previous thread and in the MacKenzie et
al 2005 book.

As for model averaging, see help(fitList). Basically, you put your
models in a fitList object, and then you use predict:

fmList <- fitList(m1, m2, m3, etc...) ᅵ# put models in a fitList object
predict(fmList, type="state") ᅵ ᅵ ᅵ ᅵ ᅵ ᅵ# expected values for


original data. or,
predict(fmList, type="state", newdata = somenewdata)

This will give you model-averaged predictions and SEs. We have
intentionally not provided capabilities for model-averaging beta
coefficients or variance-covariance matrices.

Richard

On Mon, Oct 11, 2010 at 3:37 AM, Matthew Giovanni
<matthew...@gmail.com> wrote:
> Hi Richard-
>
> I'm wondering if unmarked has functions or options to calculate and return

> AICc values from a fitList object, rather than just AIC.ᅵ Also, I was


> reading the users manual and there is some mention of calculating
> model-averaged coeffs and preds in unmarked, but I haven't been able to

> figure out an efficient way of doing so.ᅵ Any insights or suggestions?ᅵ Here
> are example data and R files if that helps.ᅵ Thanks for your help and


> expertise, as always.
>
> Matt
> ____________________________________
> Matt Giovanni
> Postdoctoral Visiting Research Fellow
> Canadian Wildlife Service
> 2365 Albert St., Room 300
> Regina, SK S4P 4K1
> 306-780-6121 work
> 402-617-3764 mobile
> Research website:
> http://sites.google.com/site/matthewgiovanni/
>

--
You received this message because you are subscribed to the Google Groups "unmarked" group.
To unsubscribe from this group and stop receiving emails from it, send an email to unmarked+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

ᅵ
ᅵ

--
You received this message because you are subscribed to the Google Groups "unmarked" group.
To unsubscribe from this group and stop receiving emails from it, send an email to unmarked+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

ᅵ
ᅵ

--
You received this message because you are subscribed to the Google Groups "unmarked" group.
To unsubscribe from this group and stop receiving emails from it, send an email to unmarked+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
ᅵ
ᅵ

--
You received this message because you are subscribed to the Google Groups "unmarked" group.
To unsubscribe from this group and stop receiving emails from it, send an email to unmarked+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
ᅵ
ᅵ

Richard Schuster

unread,
Aug 19, 2013, 4:59:18 PM8/19/13
to unma...@googlegroups.com
Sorry the second line of code should be:
model.avg(modlst, delta<2)

Pablo Oleiro

unread,
Aug 28, 2013, 11:13:10 AM8/28/13
to unma...@googlegroups.com
Richard,

I tried the dredge function and it does not work , this is the error message, that I get.
Error in names(ret) <- sapply(x@estimates@estimates, slot, "short.name") : 
  'names' attribute [3] must be the same length as the vector [2]

I was wondering if there is a dredge function for  the distsamp function. I used  with occu function and works fine. 
This whole process is because the avg function in occu gives you the average parameters for your covariates and the average of the standard errors which I need for the second part of my project. If you have a better idea to estimate the average error of my models I will appreciate . Once again, thanks for all the help and sorry for all the questions.

Pablo




Richard Schuster

unread,
Aug 29, 2013, 11:50:14 PM8/29/13
to unma...@googlegroups.com
Hi Pablo,

using the distamp example from the unmarked documentation, I have tried dredge and it works fine for me. Below the code (my additions are in bold):

data(issj)
str(issj)
jayumf <- unmarkedFrameDS(y=as.matrix(issj[,1:3]),
siteCovs=data.frame(scale(issj[,c("elevation","forest","chaparral")])),
dist.breaks=c(0,100,200,300), unitsIn="m", survey="point")

(fm1jay <- distsamp(~chaparral ~chaparral + elevation + forest, jayumf))

mm <- dredge(fm1jay)
model.avg(mm, delta<2)

As I don't use the dredge function myself and haven't seen your data I don't know what might be causing your error.
What I usually do is create the model strings using Visual Basic or R, run those, use the modSel function in unmarked and do the model averaging "manually" with a script, basically following Burnham and Anderson (2002) chapter 4 . In the past I have used Visual Basic for this, but I am planning to portage the functions to R to do the entire analysis within one R session. If you are familiar with Visual Basic I could send you what I came up with for this.

Cheers,
Richard

Am 29/08/2013 01:13, schrieb Pablo Oleiro:
Richard,

I tried the dredge function and it does not work , this is the error message, that I get.
Error in names(ret) <- sapply(x@estimates@estimates, slot, "short.name") :ᅵ
ᅵ 'names' attribute [3] must be the same length as the vector [2]

I was wondering if there is a dredge function for ᅵthe distsamp function. I used ᅵwith occu function and works fine.ᅵ
This whole process is because the avg function in occu gives you the average parameters for your covariates and the average of the standard errors which I need for the second part of my project. If you have a better idea to estimate the average error of my models I will appreciate . Once again, thanks for all the help and sorry for all the questions.

Pablo


Pablo

unread,
Sep 30, 2013, 10:57:08 PM9/30/13
to unma...@googlegroups.com
Richard,

I tried your suggestion and works fine, thank you very much. I only have a question regarding if I have a detection covariate that is a factor (example obs: A,J,E,P). When I include the Obs covariate I obtain this error 

> LBWEumf <- unmarkedFrameDS(y=as.matrix(LBWE_50mVegPercen[,5:9]),
+ siteCovs=data.frame(scale(LBWE_50mVegPercen[,c("Obs","Rain","Wind","Time","Noise","Clouds","Elev","AgroFo","Upland","SecVeg","Wetland","PN","LNElev","LNEdge","Densiometer","Canopy")])),
+ dist.breaks=c(0,10,20,30,40,50), unitsIn="m", survey="point")

Error in colMeans(x, na.rm = TRUE) : 'x' must be numeric

I believe that is because is a factor and no numeric, there is a way to identify a covariate as a factor?
any suggestions?

As always thank you very much for all your help.

Pablo

Mikey T

unread,
Feb 19, 2014, 10:06:48 AM2/19/14
to unma...@googlegroups.com

Hi,
I am having trouble with the modavg function (in package AICcmodavg) and I'm wondering if anyone can help. I keep getting the error message: object 'mod_formula' not found." This error only occurs when I attempt to get parameter estimates for occupancy (i.e., when I set parm.type='state'). I have no problem obtaining parameter estimates for detection (when parm.type='detect'). 

modavg.unmarked(cand.set=cand.mod, parm="logArea", modnames=names, second.ord=TRUE, nobs=NULL, c.hat=1, conf.level=0.95, exclude=NULL, parm.type='detect', uncond.se="revised")

Thank you for your help,
Mikey

Marc.Ma...@uqat.ca

unread,
Feb 19, 2014, 1:12:38 PM2/19/14
to unma...@googlegroups.com
Dear Mikey,

Take a look at ?modavg, specifically at the parm.type argument. You will see the appropriate values for this argument for each parameter/model types - "state" is not one of them.


Best,

Marc

--
____________________________________
Marc J. Mazerolle
Centre d'étude de la forêt
Université du Québec en Abitibi-Témiscamingue
445 boulevard de l'Université
Rouyn-Noranda, Québec J9X 5E4, Canada
Tel: (819) 762-0971 ext. 2458
Email: marc.ma...@uqat.ca

De : unma...@googlegroups.com [unma...@googlegroups.com] de la part de Mikey T [tab...@gmail.com]
Date d'envoi : mercredi 19 février 2014 10:06
À : unma...@googlegroups.com
Objet : Re: [unmarked] Re: model selection and averaging in unmarked?

Reply all
Reply to author
Forward
0 new messages