Coding site-level covariates that vary by year

posts related to the RPresence library, which may not be of general interest to users of 'classic' PRESENCE.

Coding site-level covariates that vary by year

Postby bkhobart » Wed Jan 24, 2018 3:58 pm

Hi all,

For dynamic occupancy models in RPresence, is there a way to include site-level covariates (for psi, gamma, epsilon, etc) that vary by year? For example, if I had 5 years of occupancy data and 5 years of habitat data, is there a way to make each year's (real) parameters be a function of that respective year's habitat data?

In a Presence dm, the situation I'm trying to convey could look like:

- a1 a2 a3
psi0 1 0 habitat1
eps1 0 1 habitat2
eps2 0 1 habitat3

where the number after "habitat" indicates which year of the study that habitat data is associated with (not different types of habitat).

Many thanks, Brendan
bkhobart
 
Posts: 14
Joined: Mon Oct 30, 2017 12:33 pm

Re: Coding site-level covariates that vary by year

Postby darryl » Wed Jan 24, 2018 4:12 pm

Hi Brendan,
Is that really the dm you're after? That says that the effect size of habitat is the same for both first year occupancy and extinction probability? Or would you want a fourth col and have different habitat effects size for occupancy and extinction?
Cheers
Darryl
darryl
 
Posts: 495
Joined: Thu Jun 12, 2003 3:04 pm
Location: Dunedin, New Zealand

Re: Coding site-level covariates that vary by year

Postby bkhobart » Wed Jan 24, 2018 6:14 pm

Hey Darryl,

Setting it up that way would likely make more sense, yes. I must admit - this is a fictitious example just for getting my question across in a discernible fashion. Even if the dm had 4 betas to allow for different effects on occupancy and extinction, I'd still run into issue described above for the extinction covariates (I think), thoughts?

Many thanks for your time, Brendan
bkhobart
 
Posts: 14
Joined: Mon Oct 30, 2017 12:33 pm

Re: Coding site-level covariates that vary by year

Postby darryl » Wed Jan 24, 2018 6:23 pm

No probs. Just wanted to check that before replying to the main part of your question.

You can have covariates that vary by season in RPresence. The way to do it is you define some additional covariates that are outside of the pao data object, and pass them to occMod() via the optional cov.list argument. eg:

eps.cov<-data.frame(HabYear=rbind(habitat2,habitat3))

occMod(model=list(psi~1,epsilon~HabYear,gamma~1,p~1),cov.list=list(eps.cov=eps.cov), etc...)
darryl
 
Posts: 495
Joined: Thu Jun 12, 2003 3:04 pm
Location: Dunedin, New Zealand

Re: Coding site-level covariates that vary by year

Postby bkhobart » Wed Jan 24, 2018 8:10 pm

Got it - thanks a bunch. I hadn't previously realized that the covariate commands (outside of pao) have additional functionality.

One last clarification: with the site covariate data in that format (sites as cols, seasons as rows), RPresence will recognize that the site cov values are changing seasonally?


Cheers, Brendan
bkhobart
 
Posts: 14
Joined: Mon Oct 30, 2017 12:33 pm

Re: Coding site-level covariates that vary by year

Postby bkhobart » Thu Jan 25, 2018 12:12 pm

Hey Darryl, so I'm currently having an issue defining the covariate using:

eps.cov<-data.frame(HabYear=rbind(habitat2,habitat3))

then parameterizing the model using eps~HabYear, because HabYear is not an object, but rather the col names within the eps.cov data frame. Thus I'm receiving "Error in eval(predvars, data, env) : object 'fireyear' not found".

I apologize if this is simply coding naivete on my behalf, but appreciate your input nonetheless. I've been tinkering for a few hours and have had no luck.

Cheers, Brendan
bkhobart
 
Posts: 14
Joined: Mon Oct 30, 2017 12:33 pm

Re: Coding site-level covariates that vary by year

Postby darryl » Thu Jan 25, 2018 3:26 pm

Hi Brendan,
Can you post the relevant parts of your R code for me to see please. Or send them to me off-list if you prefer.

Cheers
Darryl
darryl
 
Posts: 495
Joined: Thu Jun 12, 2003 3:04 pm
Location: Dunedin, New Zealand

Re: Coding site-level covariates that vary by year

Postby bkhobart » Thu Jan 25, 2018 3:33 pm

Certainly, will send off forum.
bkhobart
 
Posts: 14
Joined: Mon Oct 30, 2017 12:33 pm

Re: Coding site-level covariates that vary by year

Postby DMNH » Mon Jun 17, 2019 10:25 am

Hi all,
I thought it would be best to continue this thread rather than start a new one. I am trying to accomplish the same thing as @bkhobart, but haven't any luck.

I think I am confused about the format that the data has to be in before being included in occmod(). When entering site covariates into the pao the format should be sites as rows and covariates as columns, but here he asks if the format should be switched:

bkhobart wrote:One last clarification: with the site covariate data in that format (sites as cols, seasons as rows), RPresence will recognize that the site cov values are changing seasonally?


If anyone could clarify which format the data should be in and how to include habitat that varies by year into the occmod() would be greatly appreciated.

Thank you,
Devin
DMNH
 
Posts: 4
Joined: Fri Apr 19, 2019 2:13 pm

Re: Coding site-level covariates that vary by year

Postby jhines » Mon Jun 17, 2019 1:44 pm

I'm not sure why I haven't seen this thread before, but here's my reply:

Site-level covariates are entered as a matrix with N rows (sites) by K columns (site-covariates). In one of the messages here, it is reversed. The 'rbind' function in the code should have been 'cbind'. In RPresence, you can create a matrix of covariates, name the columns, then create a data.frame from the matrix. Or, just create the data.frame from individual vectors.

Jim
jhines
 
Posts: 599
Joined: Fri May 16, 2003 9:24 am
Location: Laurel, MD, USA

Next

Return to RPresence

Who is online

Users browsing this forum: No registered users and 10 guests