Shapefile Mask and Group Clarification

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

Shapefile Mask and Group Clarification

Postby adamdillon » Thu Mar 30, 2017 6:39 pm

I have two questions that I think I've figured out, but would really like some clarification on.

1) Creating a mask via shapefile.
My research is on an island and therefore I have a very defined area of study. I would like to import the shoreline shapefile as my mask for secr analysis and I've done this successfully using make.mask. My question is about the buffer that is in make.mask. I understand that make.mask can be used to create buffers around traps and then clip those buffers around a shapefile but I just want to use the shapefile itself as the mask. Is that possible and if so is it done just by removing the buffer argument in make.make? Here is my code:

Code: Select all
Traps <- read.traps ("Detection_File.txt", detector = "multi")

Capthist <- read.capthist(captfile="Capture_File.txt", trapfile="Detection_File.txt", detector = "multi", fmt="trapID", noccasions=6)

Polygon <- readShapePoly("Polygon2")

Mask <- make.mask(traps(Traps), spacing = 50, type = "polygon", poly = Polygon)


This seems to work fine, but I would appreciate clarification that it's correct

2) Creating groups. I would like to create separate groups for "sex" but I'm not sure how to input that information. Do I include M/F as an individual covariate in the Capthist and then just include g="sex" in secr.fit? I know that when you using individual covariates, you need to use the CL, so I wanted to make sure that if I enter the sex as an individual covariate in Capthist, I can still use the full likelihood if I specify them as groups.

Thanks
adamdillon
 
Posts: 21
Joined: Tue Mar 03, 2015 2:11 pm

Re: Shapefile Mask and Group Clarification

Postby murray.efford » Thu Mar 30, 2017 7:18 pm

Hi
Plotting your mask should make it obvious whether make.mask has done what you expected. I predict it will be OK, but need to hear if it failed. You may want to consider one mask for fitting and another for estimating island-wide population size with region.N.

Yes, you should specify sex as an individual covariate. There are multiple ways to use that for sex-specific analyses. Grouping is one; it does not require CL=TRUE.
Code: Select all
secr.fit(Capthist, mask = Mask, groups = 'sex', model = list(D~g, g0~g, sigma~g))
My preference (when you don't need h2 for anything else) is to use hcov = 'sex':
Code: Select all
secr.fit(Capthist, mask = Mask, hcov = 'sex', model = list(g0~h2, sigma~h2))

Note you should set hcov='sex' or groups='sex' even with (g0~1, sigma~1) (compare like models with like).

Or you could use CL=TRUE and g0~sex etc.
Murray
murray.efford
 
Posts: 686
Joined: Mon Sep 29, 2008 7:11 pm
Location: Dunedin, New Zealand

Re: Shapefile Mask and Group Clarification

Postby adamdillon » Thu Apr 06, 2017 1:26 pm

Hi Murray,

Thanks for your response.

As for pulling in the shapefile as my Mask and plotting it, everything seems to work fine which is really nice. So basically if you remove the buffer command in make.make you can import a shapefile as your mask. This has been really handy for me. And the suggestion of using one mask for fitting and another for estimating island-wide population sizes is a great idea. Using the entire island for fitting really unnecessarily increased computation time, so I've cut it down to a rather large buffer around the traps, clipped by the shoreline.

And I was able to successfully model sex differences both via groups and hcov, but I do have an additional question or two about that. If i'm using a single individual covariate "sex", then I can specify sex as either a group or hcov in secr.fit and still use the Full Likelihood, but if I have a second individual covariate "age" then it doesn't seem possible to incorporate both of these into the Full Likelihood (it gives me an error message). In this case I assume I have to assign both "age" and "sex" as individual covariates and use CL.

If I do this then I need to use derived to estimate the density. When I do this it gives me a single density for all animals combined (only a single session in this analysis). How can I get it to output the density of animals by the individual covariate "age"? In this case age is a categorical variable with only two possible values (A=adult, P=pup). Would this be doe using derive or predict? I wasn't able to figure this out but would really like estimates of density by each age group.

Thanks
adamdillon
 
Posts: 21
Joined: Tue Mar 03, 2015 2:11 pm

Re: Shapefile Mask and Group Clarification

Postby adamdillon » Thu Apr 06, 2017 1:33 pm

Actually I think I might have gotten it. I just included groups = "age" in the derived command. I thought I would have needed to have groups in my analysis for this, which I didn't. I set both "age" and "sex" as individual covariates but it seems to work fine with the follow code.
Code: Select all
derived(Buffer.400.Spacing.125.CL, groups = "age")


Let me know if you see any problem with this but I think it worked fine.
adamdillon
 
Posts: 21
Joined: Tue Mar 03, 2015 2:11 pm

Re: Shapefile Mask and Group Clarification

Postby murray.efford » Thu Apr 06, 2017 3:14 pm

Hi Adam
Yes, the 'groups' argument in derived () is what you need. Effective sampling area is computed for each individual, and they can be aggregated post hoc however you like.

Earlier you said "...if I have a second individual covariate "age" then it doesn't seem possible to incorporate both of these into the Full Likelihood (it gives me an error message)". I don't understand what you are saying - it would help to give an example of the code that doesn't work and the error message.

I have just posted a new pdf on habitat masks that you may find useful. http://www.otago.ac.nz/density/pdfs/secr-habitatmasks.pdf.
Murray
murray.efford
 
Posts: 686
Joined: Mon Sep 29, 2008 7:11 pm
Location: Dunedin, New Zealand

Re: Shapefile Mask and Group Clarification

Postby adamdillon » Thu Apr 06, 2017 4:08 pm

Hey Murray,

So here is my code with the two individual covariates.

Code: Select all
Capthist <- read.capthist(captfile="Capture_File.txt", trapfile="Detection_File.txt", detector = "multi", fmt="trapID", noccasions=6, covnames = c("age","sex"))
Polygon <- readShapePoly("Buffer400Clip")
Mask <- make.mask(traps(Capthist), spacing = 75, type = "polygon", poly = Polygon)

## Model16: D ~ age, g ~ age, s ~ b ##
D.age.g.age.s.b <- secr.fit(Capthist, model = list(D ~ age, g0 ~ age, sigma ~ b), trace = TRUE, mask=Mask, detectfn=0, hcov = "sex")


And here is the error message
Code: Select all
Checking data
Preparing detection design matrices
Error in secr.design.MS(capthist, model, timecov, sessioncov, groups,  :
  seems you are trying to use individual covariates  in a full-likelihood model


I'm entering both "age" and "sex" as individual covariates and trying to use ML, but since I am assigning "sex" to hcov, the "age" covariate remains as an individual covariate and is telling me to use a CL.

I'm doing this prior to running a larger multi-year analysis, which would be evaluating 3 major parameters: year, sex and age. I plan to break the years into sessions, but I'm not sure that if I also include sex and age that there is anyway to do this in a Full Likelihood manner. It seems like I would need to put year as a session and then both sex and age as individual covariates and use CL.
adamdillon
 
Posts: 21
Joined: Tue Mar 03, 2015 2:11 pm

Re: Shapefile Mask and Group Clarification

Postby murray.efford » Thu Apr 06, 2017 5:05 pm

Sure, that makes sense. In my haste I just didn't get that from your previous explanation. I see your problem addressing both sex and age in the context of a multi-year model. That might be an argument for looking critically at whether they really matter to D-hat (within years) before burdening the multi-year model.
Murray
murray.efford
 
Posts: 686
Joined: Mon Sep 29, 2008 7:11 pm
Location: Dunedin, New Zealand

Re: Shapefile Mask and Group Clarification

Postby adamdillon » Thu Apr 06, 2017 5:10 pm

You're one step ahead of me Murray.

Right now I'm analyzing each year separately and evaluating if both age and sex are important variables and if there would be any benefit to compile across years.

And the habitat mask file you shared is going to be really helpful for me in the very near future. My next step in the single year models is to add a habitat density surface. Once I add that complexity then I'll be able to evaluate the importance of each variable within years, and then see if there is any utility in compiling the data across years.

I really appreciate you help and feedback Murray.
Thanks again
adamdillon
 
Posts: 21
Joined: Tue Mar 03, 2015 2:11 pm

Re: Shapefile Mask and Group Clarification

Postby murray.efford » Thu Apr 06, 2017 5:13 pm

Do you recognise Fig 7c?
murray.efford
 
Posts: 686
Joined: Mon Sep 29, 2008 7:11 pm
Location: Dunedin, New Zealand

Re: Shapefile Mask and Group Clarification

Postby adamdillon » Thu Apr 06, 2017 5:34 pm

Sure do! I should be starting to analyze the Park Services fox data on both Rosa and Miguel within the next couple of weeks so this should be a great help.

I'm sure I'll have a couple more questions as I get my hands dirty with the analysis!
adamdillon
 
Posts: 21
Joined: Tue Mar 03, 2015 2:11 pm


Return to analysis help

Who is online

Users browsing this forum: No registered users and 12 guests