Nest DSR/ucl/lcl across a continuous covariate (mallard ex)

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

Nest DSR/ucl/lcl across a continuous covariate (mallard ex)

Postby lmdouglas45 » Fri Jan 15, 2021 4:30 pm

Hello everyone,

I've been working on my own data for a passerine habitat selection and survival study, and have been able to narrow down my model set to two competitive models (each of a single covariate, one is percent softwood cover and one is percent canopy cover) that best predict survival. Models that varied with time/NestAge ranked below the null model. I've been using the mallard example as a template for conducting my analysis, which has been pretty straightforward so far. However, I'm now trying to graph survival across values of a given covariate, but can't seem to do it. The mallard example offers an example for graphing survival with upper and lower confidence intervals across NestAge and PpnGrass by holding one of the two variables constant, though I'm not sure how I would do it solely across, say, JUST PpnGrass. If I wanted to get DSR with ucl and lcl across varying values of just PpnGrass, would I start with the the lines below? Or is it a different process entirely?

mallard.results$S.PpnGr$results$beta
PpnGrassSurvival<-mallard.results$S.PpnGr

I'll note that I have read all of the introductory chapters as well as the nest survival and RMark sections, though am not sure what to do here. I apologize if this question has already been asked/if there is any obvious answer that I'm not seeing. I could not find a thread with the same issue in the catalog.

Thank you in advance to anyone who can help me out.
lmdouglas45
 
Posts: 6
Joined: Tue Sep 22, 2020 11:24 am

Re: Nest DSR/ucl/lcl across a continuous covariate (mallard

Postby Rotella » Fri Jan 15, 2021 8:00 pm

If you have run the function "run.mallard" that's provided in the mallard example and have the object 'mallard.results' available in your R session, the following code can be used to create and plot the estimates of DSR (along with confidence limits) for the model that just contains "PpnGrass" across the range of observed values of "PpnGrass". Good luck with your work!
Jay

Code: Select all
# Store model results in object with simpler name
mod.PpnGr <- mallard.results$S.PpnGr

# generate range of values of PpnGrass to use for predictions
min.PpnGrass = min(mallard$PpnGrass)
max.PpnGrass = max(mallard$PpnGrass)
PpnGrass.values = seq(from = min.PpnGrass, to = max.PpnGrass, length = 100)

# make predictions
pred.PpnGrass <- covariate.predictions(mod.PpnGr,
                                       data = data.frame(PpnGrass = PpnGrass.values),
                                       indices = 1)

# store values of PpnGrass in column in pred.PpnGrass$estimates
pred.PpnGrass$estimates$PpnGrass <- PpnGrass.values
head(pred.PpnGrass$estimates)

library(ggplot2)
ggplot(pred.PpnGrass$estimates, aes(x = PpnGrass, y = estimate)) +
  geom_line() +
  geom_ribbon(aes(ymin = lcl, ymax = ucl), alpha = 0.3) +
  xlab("Proportion Grass") +
  ylab("Estimated DSR") +
  ylim(0, 1) +
  theme_bw()
Rotella
 
Posts: 72
Joined: Mon Jun 09, 2003 11:32 am

Re: Nest DSR/ucl/lcl across a continuous covariate (mallard

Postby lmdouglas45 » Mon Jan 18, 2021 2:24 pm

Hi Jay,

Thanks for the reply! Your code worked perfectly for the mallard example. Though when I input my own data (was trying to graph DSR vs. % canopy cover) I got the same DSR for every value of % canopy cover, resulting in a horizontal line at 0.974085. This is despite the fact that the model that contains % canopy cover ranked highest in my model set (including above the null model), so I would expect DSR to vary with % canopy cover. Do you (or anyone else) have any idea as to why this would be happening?
lmdouglas45
 
Posts: 6
Joined: Tue Sep 22, 2020 11:24 am

Re: Nest DSR/ucl/lcl across a continuous covariate (mallard

Postby Rotella » Mon Jan 18, 2021 6:59 pm

I'd need to see the code you're trying to use. You can share it here or send it to me at rotella@montana.edu if you'd like to me to see if I can work out what might be going on.
Jay
Rotella
 
Posts: 72
Joined: Mon Jun 09, 2003 11:32 am

Re: Nest DSR/ucl/lcl across a continuous covariate (mallard

Postby Rotella » Fri Dec 30, 2022 2:10 pm

This issue has come up for multiple people, so I'll review information that has helped in some cases where we worked through things offline. As noted in the RMark help for the 'covariate.predictions' function, when you set up the dataframe containing covariate values to be used for covariate predictions, you need to use the exact same variable names as those used in your model statement. Quoting from paragraph 3 of the Details section of the help for the 'covariate.predictions' function in RMark, which has an argument called "data",
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.
Rotella
 
Posts: 72
Joined: Mon Jun 09, 2003 11:32 am


Return to RMark

Who is online

Users browsing this forum: No registered users and 12 guests