Page 1 of 1

Trap Covariates and Varying Effort

PostPosted: Mon Mar 24, 2014 3:53 pm
by Lombardijv
Hi Murray,


I hope this question is easier to understadn than the previous question I posted last week on an older thread. I am having trouble writing my read.capthist code. The goal of my research is to distinguish how density and detection probability is influenced by different spatial covariate effects (e.g. building density, road density, area of nonurban habitat patch , percentage of nonurban habitat patch within a 250 meter around each of my 120 trap sites). Within my trap input file, I included the covariates at each trap point along with the usage (binary values) of when each camera was active.

When I wrote the following code I received an error, but I am not sure what correction needs to be made

Code: Select all
usage(traps("bobcatcapt.txt")
>NULL

CH <- read.capthist("bobcapt.txt", "CamSites.txt", trapcovnames = "BLDensity", "PercPatch", "PatchArea", "RoadDensity", detector = "proximity", fmt = "trapID", binary.usage = TRUE)

Error in read.traps(file = "CamSites.txt", detector = "proximity",  :
  'usage' fields suggest varying number of occasion



Any recommendations would be greatly appreciated as I am a bit confused on how to proceed.

Thank You Again in Advance,


Jason

Re: Trap Covariates and Varying Effort

PostPosted: Mon Mar 24, 2014 5:15 pm
by murray.efford
Hi
This looks like a simple R error. As I understand it, you have 4 columns of covariates in your trap layout file. The argument 'trapcovnames' should therefore be a character vector of length 4, which you form with the c() function:
Code: Select all
trapcovnames = c("BLDensity", "PercPatch", "PatchArea", "RoadDensity")

Murray

Re: Trap Covariates and Varying Effort

PostPosted: Fri Mar 28, 2014 3:02 pm
by Lombardijv
Murray,


Thank you for clarifying this for me, but I still received an error when I added in the correction you gave for the trap covariates. Please let me know if I made a coding error in R.

Code: Select all

usage(traps("CamSites.txt"))
>Null

CH <- read.capthist(captfile ="coyoteFALL.txt", trapfile =c("CamSites.txt"), trapcovnames = c("BLDensity", "PercPatch", "PatchArea", "RoadDensity"), detector = "proximity", fmt = "trapID", binary.usage = TRUE)

Error in read.traps(file = "CamSites.txt", detector = "proximity",  :
  'usage' fields suggest varying number of occasions



Thanks Again,


Jason

Re: Trap Covariates and Varying Effort

PostPosted: Fri Mar 28, 2014 5:05 pm
by murray.efford
The line
Code: Select all
usage(traps("CamSites.txt"))
doesn't make sense - 'traps' extracts the detectors from a capthist object, whereas "CamSites.txt" is just a character value. Not sure what you wanted to achieve here.

Otherwise there is clearly a mismatch between your data and the code, which could only be resolved by looking at (a sample of) the data. Check the format for detector layout data in secr-datainput.pdf; covariates are separated by / from preceding coordinates and usage codes.
Murray

Re: Trap Covariates and Varying Effort

PostPosted: Tue Apr 01, 2014 1:33 pm
by Lombardijv
Murray,

I looked at the secr-datainput.pdf, (as you suggested) over the weekend and figured out what was going on, which turned out to be the lack of "/" after the usage and coordinates.



Jason