Page 1 of 1

Individual covariate plotting

Posted: Wed Sep 22, 2021 8:51 pm
I am trying to plot the survival estimates for my model, which is affected by body size. I am using covariate.predictions but what I get is a straight line, indicating that larger body sizes have lower estimates of survival. Given the normal distribution of the data I was expecting a normal distribution of survival. Am I missing something from the analysis?

Re: Individual covariate plotting

Posted: Thu Sep 23, 2021 7:10 am
Hi Mardagosa,

What you are plotting is the survival probability as a function of the covariate, not the distribution of the survival values. Even then, the fact that the covariate is (approximately) normal does not mean that the survival probabilities will be normally distributed because the survival probability is (probably) a non-linear transformation of the covariate. This in part ensures that the survival probability remains between 0 and 1.

The fact that you are seeing a straight line in your plot either means that you are plotting the linear predictor or that the function is close to a straight line over the range of your covariate. The exact details depend on which link function you have selected when fitting the model (sin, logit, etc). Do the values on the y-axis make sense as probabilities (i.e., are they between 0 and 1)? If not, then you are plotting the linear predictor.

Cheers,

Simon

Re: Individual covariate plotting

Posted: Thu Sep 23, 2021 10:06 am
Hi Simon,
This makes sense and I appreciate the clarity of your explanation. Thank you so much!

Re: Individual covariate plotting

Posted: Mon Nov 01, 2021 5:48 am
Hi,
I'm sorry to ask this again, but I have the same issue, however, unfortunately didn't manage to solve it yet. I followed the code and instructions in the Appendix C and also in the Workshop notes with the weight example.
I also tried a more complex exampe with time varying covariates (temperatures) following the example "plotting environmental covariate relationships" in this forum http://www.phidot.org/forum/viewtopic.php?f=21&t=3044&p=9773&hilit=time+varying+covariates#p9773

But I always end up with a staight line and CIs and estimates that are all the same for each covariate value, no matter what I do.
Here is my very short and easy example. I would be glad if someone could tell me what's wrong.

Code: Select all
`Mnat.size.processed=process.data(Mnat.size,model="CJS",begin.time=2003,groups=c("colony"))Mnat.size.ddl=make.design.data(Mnat.size.processed)Phi.size=list(formula=~size)mod.size=mark(Mnat.size.processed, Mnat.size.ddl, model.parameters = list(Phi=Phi.size))size.seq <- seq(37,44, by=0.5)phibysize=covariate.predictions(mod.size,data=data.frame(size.seq), indices = c(1))`

All values are the same. So its no surprise that I have a straight line

Code: Select all
`> phibysize\$estimates   vcv.index model.index par.index covdata  estimate         se       lcl       ucl fixed1          1           1         1    37.0 0.8523615 0.01082037 0.8298717 0.8723357      2          2           1         1    37.5 0.8523615 0.01082037 0.8298717 0.8723357      3          3           1         1    38.0 0.8523615 0.01082037 0.8298717 0.8723357      4          4           1         1    38.5 0.8523615 0.01082037 0.8298717 0.8723357      5          5           1         1    39.0 0.8523615 0.01082037 0.8298717 0.8723357      6          6           1         1    39.5 0.8523615 0.01082037 0.8298717 0.8723357      7          7           1         1    40.0 0.8523615 0.01082037 0.8298717 0.8723357      8          8           1         1    40.5 0.8523615 0.01082037 0.8298717 0.8723357      9          9           1         1    41.0 0.8523615 0.01082037 0.8298717 0.8723357      10        10           1         1    41.5 0.8523615 0.01082037 0.8298717 0.8723357      11        11           1         1    42.0 0.8523615 0.01082037 0.8298717 0.8723357      12        12           1         1    42.5 0.8523615 0.01082037 0.8298717 0.8723357      13        13           1         1    43.0 0.8523615 0.01082037 0.8298717 0.8723357      14        14           1         1    43.5 0.8523615 0.01082037 0.8298717 0.8723357      15        15           1         1    44.0 0.8523615 0.01082037 0.8298717 0.8723357`

Code: Select all
`plot(phibysize\$estimates\$covdata, phibysize\$estimates\$estimate, type = "l", lwd=2, ylim = c(0,1))lines(phibysize\$estimates\$covdata, phibysize\$estimates\$lcl,lty=2)lines(phibysize\$estimates\$covdata, phibysize\$estimates\$ucl,lty=2)`

or if I follow the dipper rain example:

Code: Select all
`Mnat_NSH_ch_easy\$temp2002=rep(10.1,453)Mnat_NSH_ch_easy\$temp2003=rep(11.1,453)Mnat_NSH_ch_easy\$temp2004=rep(12.1,453)Mnat_NSH_ch_easy\$temp2005=rep(14.1,453)Mnat_NSH_ch_easy\$temp2006=rep(15.1,453)Mnat_NSH_ch_easy\$temp2007=rep(12.1,453)Mnat_NSH_ch_easy\$temp2008=rep(10.1,453)Mnat_NSH_ch_easy\$temp2009=rep(15.1,453)Mnat_NSH_ch_easy\$temp2010=rep(12.1,453)Mnat_NSH_ch_easy\$temp2011=rep(19.1,453)Mnat_NSH_ch_easy\$temp2012=rep(10.1,453)Mnat_NSH_ch_easy\$temp2013=rep(13.1,453)Mnat_NSH_ch_easy\$temp2014=rep(10.1,453)Mnat_NSH_ch_easy\$temp2015=rep(15.1,453)Mnat_NSH_ch_easy\$temp2016=rep(10.1,453)Mnat_NSH_ch_easy\$temp2017=rep(18.1,453)Mnat_NSH_ch_easy\$temp2018=rep(10.1,453)Mnat_NSH_ch_easy\$temp2019=rep(12.1,453)Mnat_NSH_ch_easy\$temp2020=rep(10.1,453)Mnat_NSH_ch_easy\$temp2021=rep(11.1,453)Mnat.NSH.ch.easy.processed=process.data(Mnat_NSH_ch_easy,model="CJS",begin.time=2002,groups=c("MA","colony"))Mnat.NSH.ch.easy.ddl=make.design.data(Mnat.NSH.ch.easy.processed)Phi.temp=list(formula=~temp)Phi.t<-mark(Mnat.NSH.ch.easy.processed, Mnat.NSH.ch.easy.ddl, model.parameters = list(Phi=Phi.temp, p=p.dot), adjust=TRUE)predictions=covariate.predictions(Phi.t,data=data.frame(Temp2002=10:20),indices=1)\$estimateswith(predictions,     {       plot(10:20,estimate,xlab="Rain",ylab="Survival",ylim=c(0,1))       lines(10:20,lcl,lty=2)       lines(10:20,ucl,lty=2)     })`

all estimates are the same.

Code: Select all
`predictions\$estimate [1] 0.8452862 0.8452862 0.8452862 0.8452862 0.8452862 0.8452862 0.8452862 0.8452862 0.8452862 0.8452862 0.8452862`

I have no idea why even it there's no effect, the estimates shouldn't be all the same for each value?!

Tank you
best
Bianca

Re: Individual covariate plotting

Posted: Mon Nov 01, 2021 2:04 pm
Below is from the help on covariate.predictions

The argument data is a dataframe containing values for the covariates used in the models. The names for the fields should match the names of the covariates used in the model.

size.seq is not the same as size

Now maybe I should have a message that fields in data do not match covariates, but it helps if you read the documentation especially when you are having a problem.

Re: Individual covariate plotting

Posted: Tue Nov 02, 2021 2:55 am
ok, problem solved!
Thank you!