adding temperature to daily nest survival

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

adding temperature to daily nest survival

Postby bragina » Mon May 05, 2025 12:29 am

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!
bragina
 
Posts: 2
Joined: Sun May 04, 2025 1:45 pm

Re: adding temperature to daily nest survival

Postby Rotella » Mon May 05, 2025 12:49 pm

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
Rotella
 
Posts: 73
Joined: Mon Jun 09, 2003 11:32 am

Re: adding temperature to daily nest survival

Postby jlaake » Mon May 05, 2025 7:39 pm

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
jlaake
 
Posts: 1479
Joined: Fri May 12, 2006 12:50 pm
Location: Escondido, CA

Re: adding temperature to daily nest survival

Postby bragina » Mon May 05, 2025 11:56 pm

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.
bragina
 
Posts: 2
Joined: Sun May 04, 2025 1:45 pm


Return to RMark

Who is online

Users browsing this forum: No registered users and 1 guest