Page 1 of 1

adding temperature to daily nest survival

PostPosted: Mon May 05, 2025 12:29 am
by bragina
Hi everyone,
I'm trying to analyze daily nest survival in RMark and struggling to combine spatial variables (habitat type etc) with daily temperature. Here is my code which works:
Code: Select all
S.global_noVeg = mark(data, nocc = 44, model = "Nest", model.name = "S.global_noVeg",
    groups = c('MainIsland','Landscape'),
    model.parameters = list(S=list(formula = ~ MainIsland + Landscape +
                                     DistWatM)))

In this case, data is a data frame of 81 observations, each row is one nest. Mainland, Landscape and DistWatM are covariates when each nest has 1 value corresponding to it. How do I add temperature here, which is dataframe of 44 rows (N of days in the season) and 2 columns i.e. date and temperature?
I read http://www.phidot.org/forum/viewtopic.php?f=1&t=4061 and spent a while with "Gentle introduction..." but couldn't figure this out...
Happy to provide data if there is a way to upload data here.
Thanks!

Re: adding temperature to daily nest survival

PostPosted: Mon May 05, 2025 12:49 pm
by Rotella
In the Gentle Introduction to Program MARK, Appendix C, section 6 discusses how to add and use design data for time-varying covariates (e.g., pages C-28 and C-29).

For the mallard example for nest survival, the code below shows how you could create a covariate data frame (the example below works with randomly created daily values for a variable named 'precip'; you would, of course, provide your actual values), merge the data in the data frame with the design data, and use it in a model.

Code: Select all
library(RMark)
data(mallard)
mallard$habitat <- ifelse(mallard$Native == 1, "Native",
                          ifelse(mallard$Planted == 1, "Planted",
                                 ifelse(mallard$Roadside == 1, "Roadside",
                                        "Wetland")))
# make the new variable a factor
mallard$habitat <- as.factor(mallard$habitat)

# process the data
mallard.pr <- process.data(mallard,
                           nocc=90,
                           model="Nest",
                           groups=("habitat"))

# create the default design data
mallard.ddl <- make.design.data(mallard.pr)

# create a data frame with daily values for covariate of interest 
df=data.frame(time=c(1:89), precip=rnorm(89, 10, 2))

# merge the data in 'df' with the design data
mallard.ddl$S=merge_design.covariates(mallard.ddl$S, df)

# use the time-varying covariate in a model
m.precip <- mark(mallard.pr,
                 mallard.ddl,
                 model.parameters=list(S=list(formula=~precip)))

# check beta-hats from the model
m.precip$results$beta

Re: adding temperature to daily nest survival

PostPosted: Mon May 05, 2025 7:39 pm
by jlaake
Thanks for your answer Jay.

While it is important to read and understand the material in "Gentle" Introduction it is only Appendix C that is relevant to questions specific to RMark. Additional resources are the help files for the RMark package, the package examples like mallard that Jay mentioned and the workshop notes which are more recent than Appendix C. The latter is mentioned every time you use the RMark package in R as shown below. Yet it seems to be missed quite often. I'd be interested in any suggestions to make this more obvious. --jeff

> library(RMark)
This is RMark 3.0.6
Documentation available at http://www.phidot.org/software/mark/rma ... tation.zip

Re: adding temperature to daily nest survival

PostPosted: Mon May 05, 2025 11:56 pm
by bragina
Thank you so much to both - works perfectly! Spectacled eiders' nests are negatively affected by daily temperature in Yakutia, Russia :)
I will read Appendix C. You are right, I wasn't aware of it. Would mentioning it at the beginning of key chapters help? In this case, at the beginning of 'Nest survival models' chapter? I guess a phrase 'documentation is available...' is somewhat vague given that all documentation on RMark is quite detailed and long.