Confusion over covariates

questions concerning anlysis/theory using program DENSITY and R package secr. Focus on spatially-explicit analysis.

Confusion over covariates

Postby Isoodon » Thu Jun 27, 2013 3:55 am

Hi

I have 23 grids where I trap Bandicoots. I have used one of the grid layouts (in this case wi20) as a “standard grid” so that I can use Session to estimate density across all my 23 grids. Using the script-

> library(secr)
> olddir<-setwd("~/Desktop")
> myALL<-read.capthist("isoodon with sex.txt", "wi20traps.txt", fmt="trapID", covnames=’sex’)
> secr.fit (myALL, model=list(D~session,g0~b,sigma~b), CL=FALSE, buffer=400, trace=FALSE)

This seems to work fine.

However, I am struggling with the script to incorporate sex as a covariate and then report on. When I try D~sex in the model I get an error message.

I am very new to R.

Thanks
Isoodon
 
Posts: 4
Joined: Tue Jun 25, 2013 8:50 pm

Re: Confusion over covariates

Postby murray.efford » Thu Jun 27, 2013 4:15 am

This looks familar :)

You don't say whether you want to use sex as a covariate for density (i.e. separate estimates for the density of each sex) or just detection parameters (g0, sigma). I'll assume both.

From the code you've given it looks like you successfully created a capthist object with a (presumably) categorical individual covariate 'sex'. This is sitting there waiting to be used (obviously it isn't used in your first model).

Unfortunately, there are many ways to proceed. The one I recommend is to use the new variation on mixture models which (i) is not fully documented (but see http://www.otago.ac.nz/density/pdfs/secr-finitemixtures.pdf), and (ii) estimates both total density and sex ratio.

Code: Select all
secr.fit (myALL, model=list(D~session,g0~h2,sigma~h2), hcov = 'sex', CL=FALSE, buffer=400, trace=FALSE)


[In principle you can also use this with CL=TRUE and no D in the model (save the fitted model and use derived() to get session-specific densities). BUT there is a bug in the present release that crashes R with this combination, so don't use it until I get out a new release, hopefully within days.]

Two other ways are
Code: Select all
fit <- secr.fit (myALL, model=list(g0~sex,sigma~sex), CL=TRUE, buffer=400, trace=FALSE)
derived(fit, groups = 'sex')

and
Code: Select all
secr.fit (myALL, model=list(g0~g,sigma~g), groups='sex', CL=FALSE, buffer=400, trace=FALSE)


I can't test this code, but you should get the idea.
Murray
murray.efford
 
Posts: 712
Joined: Mon Sep 29, 2008 7:11 pm
Location: Dunedin, New Zealand

Re: Confusion over covariates

Postby Isoodon » Thu Jun 27, 2013 11:26 pm

Thanks Murray,

Hopefully not overly-familiar!

I take it that I should code the model as
model=list(D~session,g0~h2+b,sigma~h2+b)
if I want to include a learned response?

Also, I have around 28 animals where sex wasn't recorded (from the total of 477 recorded). Any suggestions on how these can be dealt with in terms of constructing the script?
Isoodon
 
Posts: 4
Joined: Tue Jun 25, 2013 8:50 pm

Re: Confusion over covariates

Postby murray.efford » Fri Jun 28, 2013 1:51 am

I take it that I should code the model as
model=list(D~session,g0~h2+b,sigma~h2+b)
if I want to include a learned response?

In principle, yes. I would be less sure about combining h2 and b if you did not actually know the sex of most animals. Let me know if you have problems.

Also, I have around 28 animals where sex wasn't recorded (from the total of 477 recorded). Any suggestions on how these can be dealt with in terms of constructing the script?
Assuming you are using hcov and h2 as discussed, just record them as NA or 'U' or 'Unknown' (anything later in the alphabet than 'F' or 'M').
Murray
murray.efford
 
Posts: 712
Joined: Mon Sep 29, 2008 7:11 pm
Location: Dunedin, New Zealand


Return to analysis help

Who is online

Users browsing this forum: No registered users and 2 guests

cron