Calculating quadratic time (TT)

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

Calculating quadratic time (TT)

Postby chasingbirds » Mon Aug 01, 2022 1:09 pm

Hi all,
I'm trying to calculate quadratic time for my nest survival analysis in rMark and I'm running into an issue. I am a self-learner, and am trying my best to read through all forums/workshops/resources, so please be patient with me.

I have run several models already with linear time, nest age, DSR, etc. and am trying to add in quadratic time. I followed one line of code from another paper, and tried this:
Code: Select all
nestdata$S$TT <- as.numeric (nest.ddl$Time)^2


Though it was successful, it added a column of code to my dataframe that looks like this:
    c(0, 1, 4, 9, 16, 25 ....)

For every row (i.e. individual nest) in my dataset. I know this is incorrect, but ran the model anyway to see what the output would be, and the error says "error in dataframe, arguments imply differing number of rows: 58, 62).... misspecification of model or internal error in code."

I know I'm likely missing some step that includes time in my dataframe, but I just can't make sense of how to add it in without needed some kind of time-related covariate. I'm happy to include an example of what y dataframe looks like if that seems helpful, but I didn't want to clog up this post any more. Any help/advice would be great, and again, I apologize if this information seems obvious--I'm learning as I go!

Thanks so much!
chasingbirds
 
Posts: 9
Joined: Wed Dec 11, 2019 1:08 pm

Re: Calculating quadratic time (TT)

Postby jhines » Mon Aug 01, 2022 1:15 pm

Should be:

nest.ddl$S$TT = as.numeric(nest.ddl$S$Time)^2

Another possibility, where you don't need to create that covariate is to use the formula:

S ~ Time + I(Time ^2)
or
S ~ poly(Time,2)
jhines
 
Posts: 599
Joined: Fri May 16, 2003 9:24 am
Location: Laurel, MD, USA

Re: Calculating quadratic time (TT)

Postby jlaake » Mon Aug 01, 2022 2:14 pm

Thanks Jim. You beat me to it. I would recommend using the first approach. I have run into issues using I() and poly.

Whenever you get a problem like this, pull apart the statement and examine the contents. For example has you typed

nest.ddl$Time

You would have seen that it is NULL - doesn't exist.

--jeff
jlaake
 
Posts: 1417
Joined: Fri May 12, 2006 12:50 pm
Location: Escondido, CA

Re: Calculating quadratic time (TT)

Postby jhines » Mon Aug 01, 2022 2:26 pm

Also, I suggest looking at the design-matrix produced to make sure if does what you think it does.
jhines
 
Posts: 599
Joined: Fri May 16, 2003 9:24 am
Location: Laurel, MD, USA

Re: Calculating quadratic time (TT)

Postby B.K. Sandercock » Tue Aug 02, 2022 4:21 am

It's possible to fit a quadratic model without modifying the design matrix but by specifying the quadratic term in the model statement based on the column for the linear trend of Time. Here's a snippet of code:

Code: Select all
# DSR follows a quadratic trend through time
TimeQuad=mark(nest,nocc=occ,model="Nest",
   model.parameters=list(S=list(formula=~Time + I(Time^2))))


Good luck with your models!
B.K. Sandercock
 
Posts: 48
Joined: Mon Jun 02, 2003 4:18 pm
Location: Norwegian Institute of Nature Research


Return to RMark

Who is online

Users browsing this forum: No registered users and 14 guests

cron