Robust design: Fixing p and c at zero for two groups only

posts related to the RMark library, which may not be of general interest to users of 'classic' MARK

Robust design: Fixing p and c at zero for two groups only

Postby wijw » Mon Feb 13, 2023 8:23 pm

I have a dataset with 364 individuals that were marked and recaptured from 2018 to 2021. The data were collected from three sites. All animals were further grouped into males and females. So I have six groups in total.

My goal is to estimate annual survival and abundance at each location and I am using Robust Design (RDHuggins) model. I have four primary occasions and three secondary occasions in each. Data collection in 2020 was complicated because of the pandemic. As a result, I was unable to sample one site in 2020. In addition, the remaining two sites were only sampled on the latter two secondary occasions. I want to fix the capture and recapture probability at zero for the site I didn't survey in 2020 and the first secondary occasion for all the sites in 2020.

Code: Select all
rd.txt = import.chdata("File path",
                       header = FALSE,
                       field.names = c("ch", "freq", "location","sex"), field.types = c("n", "f","f"))

#Set time intervals between primary and secondary occasions
time.intervals = c(0,0,1,0,0,1,0,0,1,0,0)

#Create the processed dataframe and design data
rd = process.data(data = rd.txt,
                  model = "RDHuggins",
                  groups = c("location", "sex"),
                  time.intervals = time.intervals)

ddl = make.design.data(rd)

#Fix the capture and recapture probability of 2020 first secondary occasion to zero
ddl$p$fix=NA
ddl$p$fix[which(ddl$p$time==1 & ddl$p$session == 3)] = 0
ddl$c$fix=NA


I am not sure how to adjust the above code so that I can fix the p and c at 0 for just one location. I want to do this using the ddl, because all the models I run will be using this information. I read Appendix C14 where the example deals with multiple groups, but I haven't been able to figure it out.

I also did not coalesce location and sex together, because I want to be able to run all the submodels.
Last edited by wijw on Tue Feb 14, 2023 1:35 pm, edited 1 time in total.
wijw
 
Posts: 20
Joined: Mon Oct 26, 2020 2:27 pm

Re: Robust design: Fixing p and c at zero for two groups onl

Postby jlaake » Mon Feb 13, 2023 9:00 pm

Look at the fields in ddl$p and ddl$c. There should be a field called location and you can use it in the subset[] to select a specific location and time to set fix to 0.
jlaake
 
Posts: 1363
Joined: Fri May 12, 2006 12:50 pm
Location: Escondido, CA

Re: Robust design: Fixing p and c at zero for two groups onl

Postby jlaake » Mon Feb 13, 2023 9:01 pm

Look at the fields in ddl$p and ddl$c. There should be a field called location and you can use it in the subset[] to select a specific location and time to set fix to 0.
jlaake
 
Posts: 1363
Joined: Fri May 12, 2006 12:50 pm
Location: Escondido, CA

Re: Robust design: Fixing p and c at zero for two groups onl

Postby wijw » Mon Feb 13, 2023 9:52 pm

There is a location field and also a session field. I believe I have to select both fields.
I suppose my issue is not knowing R syntax. :oops:
wijw
 
Posts: 20
Joined: Mon Oct 26, 2020 2:27 pm

Re: Robust design: Fixing p and c at zero for two groups onl

Postby jlaake » Mon Feb 13, 2023 10:00 pm

Yes. That is why it is called R Mark. You need to know some basic R.
jlaake
 
Posts: 1363
Joined: Fri May 12, 2006 12:50 pm
Location: Escondido, CA

Re: Robust design: Fixing p and c at zero for two groups onl

Postby wijw » Tue Feb 14, 2023 3:51 pm

I did it this way:

First, I wanted to figure out which positions on the ddl correspond to the specific location of interest (Let's call it site B).

Code: Select all
 siteB.p = which(ddl$p$session == 3 & ddl$p$location == "siteB")
[1] 19 20 21 55 56 57

siteB.c = which(ddl$c$session == 3 & ddl$c$location == "siteB")
[1] 13 14 37 38



Then I fixed the p and c for site B in the submodel formula:

Code: Select all
p.effort = list(formula = ~effort, share = FALSE, fixed = list(index = siteB.p, value = 0, index = siteB.c, value = 0))


This worked ok.

However, when I try to also run share = TRUE, I get an error message:

Error in make.mark.model(data.proc, title = title, parameters = model.parameters, :
Cannot use fixed with share=TRUE; If you are using mark.wrapper,
use formulas within a list as in the following example
GammaDoublePrime.dot=list(GammaDoublePrime=list(formula=~1,fixed=0),GammaPrime=list(formula=~1,fixed=0))
wijw
 
Posts: 20
Joined: Mon Oct 26, 2020 2:27 pm

Re: Robust design: Fixing p and c at zero for two groups onl

Postby jlaake » Thu Feb 16, 2023 1:17 am

Actually what you thought worked could not have worked because you specified 2 sets of index and value fields in the list. It will only use one of them and yes you can't do that with share. Not sure why you went back to the old approach when your first post used the recommended approach of using fix in the ddl. If you are going to share p and c then you need to add fix to both ddl$p and ddl$c.

So you have identified the rows of the dataframe in ddl$p and ddl$c that need to be fixed to 0. So you would do

ddl$p$fix=NA
ddl$p$fix[siteB.p]=0
ddl$c$fix=NA
ddl$c$fix[siteB.c]=0

That should do what you want.

Have you read the R tutorial portion of Appendix C in Cooch and White? It may help you understanding subsetting dataframes. There are many good R tutorials online you can spend sometime with and learn R.

Jeff
jlaake
 
Posts: 1363
Joined: Fri May 12, 2006 12:50 pm
Location: Escondido, CA

Re: Robust design: Fixing p and c at zero for two groups onl

Postby wijw » Thu Feb 16, 2023 1:22 pm

Thank you, I will try that. I realize it is very similar to how I set up p=0 in 2020.
I have read appendix C several times, but I should pay more attention to subsetting.
wijw
 
Posts: 20
Joined: Mon Oct 26, 2020 2:27 pm


Return to RMark

Who is online

Users browsing this forum: No registered users and 1 guest

cron