I worked with Reed on this offlist. I missed that this was a time varying individual covariate which are contained in the data with the capture history and for his situation were named temp1,...temp6 for the 6 sessions in the robust design. As it turns out, the data he supplied to covariate.predictions only contained the variable temp1 and that is sufficient if you only use indices for session1. When he used an index for session 6, it gave constant predictions because it did not find temp6 in the data argument. When covariate.predictions doesn't find a covariate in the data argument that is used in the design matrix, it uses the average covariate value for the prediction and thus the predictions will be constant for the values used in data.
Below I create some dummy time varying individual covariates for Phi in the dipper data to demonstrate.
- Code: Select all
library(RMark)
data(dipper)
dipper$temp1=runif(294,0,1)
dipper$temp2=runif(294,0,1)
dipper$temp3=runif(294,0,1)
dipper$temp4=runif(294,0,1)
dipper$temp5=runif(294,0,1)
dipper$temp6=runif(294,0,1)
dp=process.data(dipper,model="CJS")
ddl=make.design.data(dp)
model=mark(dp,ddl,model.parameters = list(Phi=list(formula=~temp)))
If you look at the design matrix you will see that the entries are temp1,...temp6 for the 6 possible Phi values in the simplified model structure.
- Code: Select all
> model$design.matrix
Phi:(Intercept) Phi:temp p:(Intercept)
Phi g1 c1 a0 t1 "1" "temp1" "0"
Phi g1 c1 a1 t2 "1" "temp2" "0"
Phi g1 c1 a2 t3 "1" "temp3" "0"
Phi g1 c1 a3 t4 "1" "temp4" "0"
Phi g1 c1 a4 t5 "1" "temp5" "0"
Phi g1 c1 a5 t6 "1" "temp6" "0"
p g1 c1 a1 t2 "0" "0" "1"
If you pick a model.index from ddl.Phi that corresponds to time 1 it will use the first row in the simplified structure which contains temp1 and if you use a model.index for time 6 it will the 6th row containing temp6. If you were to choose those, you would need to include values for temp1 and temp6. Below I show what happens when you do it incorrectly and then correctly.
- Code: Select all
> covariate.predictions(model,data=data.frame(temp1=c(0,.5,1)),indices=c(1,6))
$estimates
vcv.index model.index par.index covdata estimate se lcl ucl fixed
1 1 1 1 0.0 0.5082236 0.05316857 0.4051506 0.6106021
2 2 6 6 0.0 0.5585437 0.02523609 0.5086633 0.6072700
3 3 1 1 0.5 0.5599992 0.02519812 0.5101794 0.6086390
4 4 6 6 0.5 0.5585437 0.02523609 0.5086633 0.6072700
5 5 1 1 1.0 0.6105015 0.05103428 0.5071930 0.7047597
6 6 6 6 1.0 0.5585437 0.02523609 0.5086633 0.6072700
$vcv
[,1] [,2] [,3] [,4] [,5] [,6]
[1,] 0.0028268967 0.0006932227 0.0006316270 0.0006932227 -0.0014704436 0.0006932227
[2,] 0.0006932227 0.0006368601 0.0006350426 0.0006368601 0.0005661585 0.0006368601
[3,] 0.0006316270 0.0006350426 0.0006349454 0.0006350426 0.0006245740 0.0006350426
[4,] 0.0006932227 0.0006368601 0.0006350426 0.0006368601 0.0005661585 0.0006368601
[5,] -0.0014704436 0.0005661585 0.0006245740 0.0005661585 0.0026044975 0.0005661585
[6,] 0.0006932227 0.0006368601 0.0006350426 0.0006368601 0.0005661585 0.0006368601
> covariate.predictions(model,data=data.frame(temp1=c(0,.5,1),temp6=c(0,0.5,1)),indices=c(1,6))
$estimates
vcv.index model.index par.index temp1 temp6 estimate se lcl ucl fixed
1 1 1 1 0.0 0.0 0.5082236 0.05316857 0.4051506 0.6106021
2 2 6 6 0.0 0.0 0.5082236 0.05316857 0.4051506 0.6106021
3 3 1 1 0.5 0.5 0.5599992 0.02519812 0.5101794 0.6086390
4 4 6 6 0.5 0.5 0.5599992 0.02519812 0.5101794 0.6086390
5 5 1 1 1.0 1.0 0.6105015 0.05103428 0.5071930 0.7047597
6 6 6 6 1.0 1.0 0.6105015 0.05103428 0.5071930 0.7047597
$vcv
[,1] [,2] [,3] [,4] [,5] [,6]
[1,] 0.002826897 0.002826897 0.0006316270 0.0006316270 -0.001470444 -0.001470444
[2,] 0.002826897 0.002826897 0.0006316270 0.0006316270 -0.001470444 -0.001470444
[3,] 0.000631627 0.000631627 0.0006349454 0.0006349454 0.000624574 0.000624574
[4,] 0.000631627 0.000631627 0.0006349454 0.0006349454 0.000624574 0.000624574
[5,] -0.001470444 -0.001470444 0.0006245740 0.0006245740 0.002604498 0.002604498
[6,] -0.001470444 -0.001470444 0.0006245740 0.0006245740 0.002604498 0.002604498
Now in this dummy example they are all the same and you wouldn't choose a model.index for both 1 and 6 but in more complex examples you might have a separate intercept per time or a separate slope per time, in which case you would need to specify all of the indices and a range for all of the tempx values for x=1,...,6.