Multistates model with covariates in RMArk

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

Multistates model with covariates in RMArk

Postby shubhaPAndit » Sun Nov 22, 2015 2:45 pm

Hi forum members,
I am new here and trying to use RMark to determine the transitions probabilities between two states with the the effect of covariates.But, I got stuck and have been struggling to figure it out.

I have three occasions (time 3) in which first was captured and released with marking, second and third are recapture. Besides these, I have 6 states (startum) I want to determine
1. whether the movement is based on the temp, flow or area: Psi(AB), Psi(AC), … Psi(AF), is it going to depend on temp, flow, and/or area in A or
2. whether this relationship vary with body length.

The example of the data is:
0A0 1 80
0A0 1 86
0A0 1 86
E00 1 80
AF0 1 95
0A0 1 90
A00 1 81
A00 1 84
A00 1 86
A00 1 80
AF0 1 88
0A0 1 89
AF0 1 86
AF0 1 90
AF0 1 92
0A0 1 102
0A0 1 87
0A0 1 93
A00 1 103
A00 1 85
0A0 1 95
A00 1 90
0A0 1 90
A00 1 93
0A0 1 91
A00 1 88
A00 1 112
0A0 1 88

I used the following code
[example<-import.chdata("example",field.names=c("ch", "freq", "length"),
field.type=c("n","n"),header=FALSE)]

# to add the covariates, I used the following code but did not work

mypvars=data.frame(stratum=c("A","B","C","D","E","F"),Area=c(280,150,210,190,65,200),
temperature=c("18","17","18.5","19","17","18"),flow=c("31.5","29.7","21.1","54.2","15.7","49.3"))

# Process data ( this also did not work for me)
ms.pr=process.data(example, begin.time = 2010,model = "Multistrata")
​ms.ddl=make.design.data(ms.pr,mypvars)​
ms.dd1$p=merge_design.covariates(ms.dd1$p,mypvars)
ms.dd1$S=merge_design.covariates(ms.dd1$p,mypvars)
ms.dd1$Psi=merge_design.covariates(ms.dd1$p,mypvars)

​I want to put the following model to calculate transitions probabilities (whether transition between sites is based on temperature, flow, or area or combination of all). But I don't know how I can build the models.
1. Psi+temperature
2. Psi+flow
3. Psi+ Area
4. Psi+temperature+flow+Area

whether this relationship vary with body length.

I am really looking forward to getting your some hints that will help me a lot. I would be very obliged with your help.

Thank you,

shubha
shubhaPAndit
 
Posts: 6
Joined: Sun Nov 22, 2015 12:52 pm

Re: Multistates model with covariates in RMArk

Postby jlaake » Mon Nov 23, 2015 1:48 pm

You need to slow down and read the documentation and learn some R. Coding should be a deliberate process. There is nothing in the documentation that would suggest that you would include the variable mypvars in the call to make.design.data. Read the help and understand the arguments and what they do. In your code for merge_design.covariates you are assigning the result to the design data for p to each of the other parameters. Also, if you read the help for merge_design.covariates you'll see that it is for merging values that vary by time but there is no capability to merge based on stratum. You are not restricted to using merge_design.covariates. The design data list is a list of dataframes. You can modify a dataframe with any valid R function. To do what you want you can use match or even a sequence of simple R statements:

Code: Select all
ms.pr=process.data(example, begin.time = 2010,model = "Multistrata")
​ms.ddl=make.design.data(ms.pr)​
ms.ddl$p$Area=NA
ms.ddl$p$temperature=NA
ms.ddl$p$flow=NA
ms.ddl$p$Area[ms.ddl$p$stratum=="A"]=280
ms.ddl$p$temperature[ms.ddl$p$stratum=="A"]=18
ms.ddl$p$flow[ms.ddl$p$stratum=="A"]=31.5
.
.
.


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


Return to RMark

Who is online

Users browsing this forum: No registered users and 3 guests