Page 1 of 1

Coding BACI time component in RMark

PostPosted: Mon Apr 15, 2019 1:30 pm
by krh1985
Hello,
I have been working through App C but just want to make sure I'm coding my BACI experimental design properly in RMark. Experimental design: 11 small mammal CMR sessions (4 pre-treatment, 7 post-treatment). 3 control/3 treatment plots. Equal capture effort across all plots. I have created a simple group for trt/control but was unsure how to code the before/after component of the BACI because I have individuals captured in sessions both before and after the treatment was applied. So far I've ran it using the dipper data flood example, creating a new field for each parameter called BACI and coding times 1-4 with a 0 (pre-treatment) and times 5-11 with a 1 (post-treatment). Then I'm simply modeling trt+BACI and trt*BACI along with the other candidate models. Does that seem right? Is it that simple? Any advice is appreciated. Thanks!! -Katie

Here's my code:

cr.proc=process.data(cr,model="Pradlambda",groups=c("trt"),time.intervals=c(1,1,1,1,1,1,1,1,1,1),nocc=11)

## create default design data
cr.ddl=make.design.data(cr.proc, parameters=list(Phi=list(pim.type="time"),p=list(pim.type="time"),Lambda=list(pim.type="time")))
cr.ddl$Phi$BACI=0
#fill in BACI data
cr.ddl$Phi$BACI[cr.ddl$Phi$time==5|cr.ddl$Phi$time==6|cr.ddl$Phi$time==7|cr.ddl$Phi$time==8|cr.ddl$Phi$time==9|cr.ddl$Phi$time==10|cr.ddl$Phi$time==11]=1
#make new field in p
cr.ddl$p$BACI=0
#fill in BACI data
cr.ddl$p$BACI[cr.ddl$p$time==5|cr.ddl$p$time==6|cr.ddl$p$time==7|cr.ddl$p$time==8|cr.ddl$p$time==9|cr.ddl$p$time==10|cr.ddl$p$time==11]=1
cr.ddl$Lambda$BACI=0
cr.ddl$Lambda$BACI[cr.ddl$Lambda$time==5|cr.ddl$Lambda$time==6|cr.ddl$Lambda$time==7|cr.ddl$Lambda$time==8|cr.ddl$Lambda$time==9|cr.ddl$Lambda$time==10|cr.ddl$Lambda$time==11]=1

###create function called initial.analysis to create initial set of models and find the best model for capture probabilty.
initial.analysis=function(){

Phi.time=list(formula=~time)
p.dot=list(formula=~1)
p.trt=list(formula=~trt)
p.time=list(formula=~time)
p.BACI=list(formula=~BACI)
p.trtplusBACI=list(formula=~BACI+trt)
p.trtxBACI=list(formula=~BACI*trt)

Lambda.time=list(formula=~time)
#use create.model.list to construct the models and store in object named cr.cml
cr.cml=create.model.list("Pradlambda")
#use mark.wrapper with model list cr.CML and the processed data and design data to fit each of the models in MARK
model.list=mark.wrapper(cr.cml,data=cr.proc,ddl=cr.ddl,output=F)
#results=mark.wrapper(cr.cml,data=cr.proc,ddl=cr.ddl,adjust=T,invisible=F)
#return the list of model results as the value of the fnction
return(model.list)
}

Re: Coding BACI time component in RMark

PostPosted: Mon Apr 15, 2019 9:42 pm
by jlaake
It is that simple but why is BACI and try effect on p rather than phone or lambda especially when you said you have equal effort Capture?

Re: Coding BACI time component in RMark

PostPosted: Tue Apr 16, 2019 11:12 am
by krh1985
Thanks for your quick reply, Jeff!
I'm analyzing all parameters, not just p. My advisor has had me running sets of models focusing on individual parameters (this example was for p) while constraining the other parameters then taking the estimates from those model sets and informing the next set of models for the next parameter. Glad to hear I'm on the right track with the BACI timing! -Katie

Re: Coding BACI time component in RMark

PostPosted: Tue Apr 16, 2019 2:52 pm
by jlaake
Not exactly the way I would go about things but that is up to you. I wouldn't propose models for a parameter like p that didn't make sense a priori. You could end up with a bogus model by pure chance with no good explanation for it. Instead I would suggest proposing a set of models for each parameter that made sense for your sampling situation and the biology of the critter. Then fit the combinations of those parameters which will make a sufficiently rich set of models. But it is your analysis.

Also, beware that the definition of BACI using time may depend on whether the parameter is an occasion parameter like p versus an interval parameter like Phi but not sure for this case. Just note the differences in the way time is assigned to the parameters in the design data.

Re: Coding BACI time component in RMark

PostPosted: Tue Apr 16, 2019 2:56 pm
by jlaake
PS I would suggest using the Workshop notes in addition to Appendix C because it is more up to date.

Re: Coding BACI time component in RMark

PostPosted: Wed Apr 17, 2019 5:00 pm
by krh1985
jlaake wrote:PS I would suggest using the Workshop notes in addition to Appendix C because it is more up to date.


Will do! Thanks for the advice, I'll discuss with my advisor on the best way to model it based on our study species and experimental design. -Katie