Quadratic Trend on Session

questions concerning anlysis/theory using program DENSITY and R package secr. Focus on spatially-explicit analysis.

Quadratic Trend on Session

Postby adamdillon » Mon Jan 08, 2018 1:39 pm

I am running multi-year models that span 10 years, with each year being a separate session. I am trying to create models that contain a quadratic trend in g0 and sigma across sessions (years), but I'm having no luck.
To keep it simple I will only talk about models concerning g0 here.

When I run the following model...

MODEL 1:
D.year.g.year.s.1 <- secr.fit(Capthist, model = list(D ~ session, g0 ~ session, sigma ~ 1), trace = TRUE, mask=c(Mask.2008, Mask.2009, Mask.2010, Mask.2011, Mask.2012, Mask.2013, Mask.2014, Mask.2015, Mask.2016), detectfn=0, hcov='sex')

Density is estimated for each year separately (which is what I want) and g0 is also estimated for every year separately, with a single intercept corresponding to the first year and additional parameters corresponding to each additional year of the study.

When I run the following model...

MODEL 2:
D.year.g.year.trend.s.1 <- secr.fit(Capthist, model = list(D ~ session, g0 ~ Session, sigma ~ 1), trace = TRUE, mask=c(Mask.2008, Mask.2009, Mask.2010, Mask.2011, Mask.2012, Mask.2013, Mask.2014, Mask.2015, Mask.2016), detectfn=0, hcov='sex')

Density is estimated for each year separately (which is what I want) and g0 is estimated as a linear trend across sessions (years), with a single intercept and one additional parameters corresponding to the linear tend in g0.

I am now trying to incorporate a quadratic trend in g0 across sessions (years) but with no luck. When I run the follow 2 models, with or without parenthesis around Session...

MODEL 3:
D.year.g.year.trend.2.s.1 <- secr.fit(Capthist, model = list(D ~ session, g0 ~ (Session)^2, sigma ~ 1), trace = TRUE, mask=c(Mask.2008, Mask.2009, Mask.2010, Mask.2011, Mask.2012, Mask.2013, Mask.2014, Mask.2015, Mask.2016), detectfn=0, hcov='sex')

MODEL 4:
D.year.g.year.trend.2.s.1 <- secr.fit(Capthist, model = list(D ~ session, g0 ~ Session^2, sigma ~ 1), trace = TRUE, mask=c(Mask.2008, Mask.2009, Mask.2010, Mask.2011, Mask.2012, Mask.2013, Mask.2014, Mask.2015, Mask.2016), detectfn=0, hcov='sex')

...the program simply ignores the squared term and instead estimates a linear trend in g0 across sessions (year) exactly like MODEL 2 above.

When I run the follow 2 models, with or without parenthesis around session...

MODEL 5:
D.year.g.year.trend.2.s.1 <- secr.fit(Capthist, model = list(D ~ session, g0 ~ (session)^2, sigma ~ 1), trace = TRUE, mask=c(Mask.2008, Mask.2009, Mask.2010, Mask.2011, Mask.2012, Mask.2013, Mask.2014, Mask.2015, Mask.2016), detectfn=0, hcov='sex')

MODEL 6:
D.year.g.year.trend.2.s.1 <- secr.fit(Capthist, model = list(D ~ session, g0 ~ session^2, sigma ~ 1), trace = TRUE, mask=c(Mask.2008, Mask.2009, Mask.2010, Mask.2011, Mask.2012, Mask.2013, Mask.2014, Mask.2015, Mask.2016), detectfn=0, hcov='sex')

...the program again ignores the squared term and instead estimates a separate g0 for each separate year exactly like MODEL 1 above.

So how do I correctly incorporate a quadratic trend in g0 across sessions (years)?

Thanks
Adam
adamdillon
 
Posts: 16
Joined: Tue Mar 03, 2015 2:11 pm

Re: Quadratic Trend on Session

Postby murray.efford » Mon Jan 08, 2018 3:39 pm

'secr' does not directly allow polynomial terms in the model formula (except for density D via the 'canned' predictors x2 and y2). However, you can easily construct the quadratic using a session-level covariate.
Code: Select all
scov <-  data.frame(Sess = 1:5, Sess2 = (1:5)^2)
fit <- secr.fit(ovenCH, buffer=300, model = g0~Sess + Sess2, sessioncov = scov)

Note that sessioncov is a dataframe with one row for each session, and the quadratic is on the link scale (default logit for g0). You could use the builtin Session instead of Sess for the linear term, but it's convenient to just re-use scov for prediction:
Code: Select all
predict(fit, newdata = scov)
# plot to confirm
plot(sapply(predict(fit, newdata = scov), '[', 'g0','estimate'))

Murray
murray.efford
 
Posts: 523
Joined: Mon Sep 29, 2008 7:11 pm
Location: Dunedin, New Zealand


Return to analysis help

Who is online

Users browsing this forum: No registered users and 1 guest