You can add design data with any R commands in both marked and RMark. Here is a simple dummy example using RMark/MARK in which I use the rudimentary approach of assigning each value. Note they should be symmetric obviously (distance from A to B same as B to A). Would work very similarly in marked. Note that I have this structured so that probability of remaining in the stratum is done by subtraction. That is the only way I can conceive of it working because you can't set the covariate value for the one computed by subtraction. One could also have ~stratum+distance such that probability of remaining is strata dependent but because Psi values sum to 1, this will happen to some degree without a stratum specific intercept. This is made clear by writing down formula for strata A and strata B using the values I assign in code below and beta is slope for distance and intercept is the Psi intercept value.
Psi A to B = exp(intercept + 10*beta)/[1+exp(intercept + 10*beta)+exp(intercept + 20*beta)]
Psi A to C = exp(intercept + 20*beta)/[1+exp(intercept + 10*beta)+exp(intercept + 20*beta)]
Psi A to A = 1/[1+exp(intercept + 10*beta)+exp(intercept + 20*beta)]
Psi B to A = exp(intercept + 10*beta)/[1+exp(intercept + 10*beta)+exp(intercept + 15*beta)]
Psi B to C = exp(intercept + 15*beta)/[1+exp(intercept + 10*beta)+exp(intercept + 15*beta)]
Psi B to B = 1/[1+exp(intercept + 10*beta)+exp(intercept + 15*beta)]
But intercept can still be stratum dependent as well. It is essential to understand fully the mlogit link because it has implications on how you can construct the formula and what it is doing for the model you are using.
- Code: Select all
library(RMark)
data(mstrata)
dp=process.data(mstrata,model="Multistrata")
ddl=make.design.data(dp)
head(ddl$Psi)
# the following is only done to catch errors if I forgot to assign one of the values; an NA will create an error
ddl$Psi$distance=NA
ddl$Psi$distance[ddl$Psi$stratum=="A"&ddl$Psi$tostratum=="B"]=10
ddl$Psi$distance[ddl$Psi$stratum=="A"&ddl$Psi$tostratum=="C"]=20
ddl$Psi$distance[ddl$Psi$stratum=="B"&ddl$Psi$tostratum=="A"]=10
ddl$Psi$distance[ddl$Psi$stratum=="B"&ddl$Psi$tostratum=="C"]=15
ddl$Psi$distance[ddl$Psi$stratum=="C"&ddl$Psi$tostratum=="A"]=20
ddl$Psi$distance[ddl$Psi$stratum=="C"&ddl$Psi$tostratum=="B"]=15
mark(dp,ddl,model.parameters=list(Psi=list(formula=~distance)))