Page 1 of 1

RMark multi-strata with covariates for psi

PostPosted: Tue Oct 02, 2007 12:34 pm
by Rotella
I would like to use RMark for a multi-strata model in which transition probabilities are modeled as functions of covariates that are specific to pairs of strata, e.g., distance between locations. Is it possible to do this? And, if it is possible, what is a reasonable way to specify the covariate values for pairs of strata and to use those in a model.

Using the example under the RMark help for the 'mstrata' function, how might I use these distances for the strata A, B, C to model the movement probabilities between strata as (1) a function of distance only and (2) a function of distance and time?

A B C
A 0 12 5
B 0 2
C 0

Thanks in advance for any help.
Jay Rotella

RMark code

PostPosted: Tue Oct 02, 2007 4:23 pm
by jlaake
The following code will do what you want using the mstrata example you posed. What I'm not sure of is how this fits in with the mlogit link which is the only link implementation in RMark for Psi. In particluar, I'm not sure how the intercept of distance=0 ties in with the subtract-stratum values for AtoA, BtoB and CtoC. I'll leave that up to you to work out.


run.mstrata=function()
{
# Process data
mstrata.processed=process.data(mstrata,model="Multistrata")
# Create default design data
mstrata.ddl=make.design.data(mstrata.processed)
# Add distance covariate
mstrata.ddl$Psi$distance=0
mstrata.ddl$Psi$distance[mstrata.ddl$Psi$stratum=="A"&mstrata.ddl$Psi$tostratum=="B"]=12
mstrata.ddl$Psi$distance[mstrata.ddl$Psi$stratum=="A"&mstrata.ddl$Psi$tostratum=="C"]=5
mstrata.ddl$Psi$distance[mstrata.ddl$Psi$stratum=="B"&mstrata.ddl$Psi$tostratum=="C"]=2
mstrata.ddl$Psi$distance[mstrata.ddl$Psi$stratum=="B"&mstrata.ddl$Psi$tostratum=="A"]=12
mstrata.ddl$Psi$distance[mstrata.ddl$Psi$stratum=="C"&mstrata.ddl$Psi$tostratum=="A"]=5
mstrata.ddl$Psi$distance[mstrata.ddl$Psi$stratum=="C"&mstrata.ddl$Psi$tostratum=="B"]=2
# Create formula
Psi.distance=list(formula=~distance)
Psi.distance.time=list(formula=~distance+time)
p.stratum=list(formula=~stratum)
S.stratum=list(formula=~stratum)
model.list=create.model.list("Multistrata")
mstrata.results=mark.wrapper(model.list,data=mstrata.processed,ddl=mstrata.ddl)
return(mstrata.results)
}
mstrata.results=run.mstrata()
mstrata.results