covariate.predictions MSLD model stratum/movement

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

covariate.predictions MSLD model stratum/movement

Postby nturner » Wed Mar 18, 2020 4:55 pm

Hi,

Wondering if someone can point me in the right direction for working with mlogit and covariate.predictions

I am looking to plot stratum A and stratum B covariate predictions for estimated movement and fork length at time of tagging (individual covariates)

I have been successful estimating and plotting these for survival but am having trouble interpreting what exact changes I need to make when working with mlogit movement estimates...

my code for estimating survival fork length covariate predictions
Code: Select all
#stratum A
S.length.predictions.FL=covariate.predictions(top.models,data=data.frame(index=rep(1),FL=rep(344:735,1)))
#stratum B
S.length.predictions.FLB=covariate.predictions(top.models,data=data.frame(index=rep(5779),FL=rep(344:735,1)))
#where fork length ranges form 344 - 735 and index=rep is and index from each of the survival stratum (A/B)


Under covariate.predictions reads:
"However, if you are making the computations for parameters that use an mlogit link you must use the separate indices argument. If you try to use the data.frame(index=...,cov) approach with mlogit parameters and you have covariate values, the function will stop with an error."

I'm just not exactly sure what this is telling me to do as there is no argument for separate indices. Some further explanation to help me work through this code would be so appreciated.

Thanks in advance
nturner
 
Posts: 8
Joined: Mon Dec 09, 2019 3:30 pm

Re: covariate.predictions MSLD model stratum/movement

Postby jlaake » Wed Mar 18, 2020 5:20 pm

> args(covariate.predictions)
function (model, data = NULL, indices = NULL, drop = TRUE, revised = TRUE,
mata = FALSE, normal.lm = FALSE, residual.dfs = 0, alpha = 0.025,
...)


Use the separate argument indices rather than index in data. When you use indices instead of index it computes each real parameter specified in indices at each of the covariate values. Also, specify indices of all of the parameters in a transition set. If you have A,B,C, then for instance use indices for A to B and A to C. If you only have 2 strata (A,B) then you could just specify one indices value. It is better to use R code to find the indices values. If you change the ddl the indices could change.
jlaake
 
Posts: 1479
Joined: Fri May 12, 2006 12:50 pm
Location: Escondido, CA

Re: covariate.predictions MSLD model stratum/movement

Postby nturner » Thu Mar 19, 2020 3:09 pm

Hi,
Thanks for the reply. So I think I understand a bit more clearly now. However when trying to troubleshoot the problem and test out code, I am unable to get this to work with any of the following variations

Code: Select all
covariate.predictions(Top.model1,indices=5671, FL=rep(344:735,1))
covariate.predictions(Top.model1,indices=c(5671),data=data.frame(FL=rep(344:735,1)))
covariate.predictions(Top.model1,FL=rep(344:735,1),indices=1:5671)
covariate.predictions(Top.model1,indices=1:5671)


Im not getting any errors pop up but code seems to be stuck running for hours with no results..
nturner
 
Posts: 8
Joined: Mon Dec 09, 2019 3:30 pm

Re: covariate.predictions MSLD model stratum/movement

Postby jlaake » Tue Mar 24, 2020 10:15 pm

The covariate.predictions function computes the variance-covariance matrix of the estimates. So if you specify indices 1:5671 and FL values from 344:735 that is 392*5671 real values so the variance-covariance matrix is 2+million by 2+million elements which is huge. So no surprise that it took long. Unless you have time and other sources of variation in Psi, you don't need to compute it for all 5671 Psi parameters. But you can't also just do it for one Psi because that is for a single transition and presumably you want all of the possible transitions. Here is an example using the mstrata data.

Code: Select all
data(mstrata)
head(mstrata)
mstrata$FL=rnorm(nrow(mstrata),100,10)
mstrata
mod=mark(mstrata,model="Multistrata",model.parameters=list(Psi=list(formula=~-1+stratum:tostratum+stratum:tostratum:FL)))
mod
summary(mod,brief=T)
dp=process.data(mstrata,model="Multistrata")
ddl=make.design.data(dp)
mod=mark(dp,ddl,model.parameters=list(Psi=list(formula=~-1+stratum:tostratum+stratum:tostratum:FL)))
ddl$Psi[ddl$Psi$time==1,
]
covariate.predictions(mod,indices=ddl$Psi$model.index[ddl$Psi$time==1],data=data.frame(FL=90:110))
pred=covariate.predictions(mod,indices=ddl$Psi$model.index[ddl$Psi$time==1],data=data.frame(FL=90:110))
jlaake
 
Posts: 1479
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 1 guest