kaitlyngaynor / gorongosa-mesocarnivores

2 stars 0 forks source link

how to have more than one yearlysitecov #109

Open klg-2016 opened 3 years ago

klg-2016 commented 3 years ago

https://github.com/kaitlyngaynor/gorongosa-mesocarnivores/blob/d0160437209da15344cc3a53683db9cf45ef39e6/scripts/multi-season%20model/01-multi-season-data-prep.R#L165

This might be basic, but I'm struggling with what format the data needs to be in to have more than one covariate that changes across the years. Right now, this line assigns the yearlySiteCovs to be a two column list with 2016 and 2017 written out for each site. That's fine, but how do we add other covariates? If you just add additional columns (i.e. a column with 2016 lion data and a column with 2017 lion data), how do you tell the model/code that those are for one covariate across two separate years? Do we need an array for the yearlysitecovs? The crossbill sample data/code that I worked through only uses year for this covariate, and I haven't dug in fully to Kendall's code to see what he does (I have his code and my multi-season code in 2 different projects in R, so I need to close one to get to the other).

klg-2016 commented 3 years ago

If I understand Kendall's code, he doesn't use year as a yearly site cov. Instead he uses a burn metric. I don't follow the loop(s) he's using to set up that value, but I think he's only using the one value (so one value for each site for each year, corresponding to "burned"-ness).

kaitlyngaynor commented 3 years ago

I can't answer this off the top of my head, but in response to this:

I have his code and my multi-season code in 2 different projects in R, so I need to close one to get to the other

If you are using R Studio, you can go to File > Open Project in New Session and have two windows open! (You can also open up a script in a project even if it's not in that project folder)

klg-2016 commented 3 years ago

Magic! Thank you :)

kaitlyngaynor commented 3 years ago

Hmm okay. I had a look at this documentation: https://www.rdocumentation.org/packages/unmarked/versions/1.0.1/topics/unmarkedMultFrame

And they say "yearlySiteCovs is a data frame with MT [sites * years] rows which are in site-major, year-minor order" So maybe each column corresponds to a variable, and each row to a site-year? Not sure if that's helpful. I haven't dug in too deeply :)

klg-2016 commented 3 years ago

OK that's definitely helpful. I'm not familiar with the "site-major, year-minor" way of describing stuff--would you read that as all the rows for the first year, followed by all those for the second, third, etc?

kaitlyngaynor commented 3 years ago

Yeah this one was new to me, too. It's either that, OR all of the rows for a given camera (year 1, year 2, etc), followed by all years for the next camera.... important to figure out, and merits a bit more research

There's always Wikipedia ;) https://en.wikipedia.org/wiki/Row-_and_column-major_order#:~:text=A%20general%20way%20to%20order,major%20and%20the%20last%20minor .

On Fri, Mar 12, 2021 at 10:10 AM klg-2016 @.***> wrote:

OK that's definitely helpful. I'm not familiar with the "site-major, year-minor" way of describing stuff--would you read that as all the rows for the first year, followed by all those for the second, third, etc?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kaitlyngaynor/gorongosa-mesocarnivores/issues/109#issuecomment-797665012, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHA7WTZXHT5G77SJDBNLEN3TDJDIVANCNFSM4W7W4LGQ .

klg-2016 commented 3 years ago

I read the wikipedia info as suggesting that what you said is correct?

kaitlyngaynor commented 3 years ago

Yeah I would agree

On Fri, Mar 12, 2021 at 7:01 PM klg-2016 @.***> wrote:

I read the wikipedia info as suggesting that what you said is correct?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kaitlyngaynor/gorongosa-mesocarnivores/issues/109#issuecomment-797855309, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHA7WT2EYRMNOEFXROTX6FDTDLBQDANCNFSM4W7W4LGQ .

klg-2016 commented 3 years ago

OK so thinking about the format I need this data in: It's going to be a data frame with 3 columns and 240 rows First column will correspond to "years", and be 2016 2017 2018 2019 ...repeated for each camera (not entirely sure why/if we need this but "years" as a yearlysitecov was pretty common when I was looking at examples of this stuff)

Second column will correspond to lion presence, and be 2016 lion value 2017 lion value 2018 lion value 2019 lion value ...repeated for each camera

Third column will correspond to wild dog presence in the same way.

Does that sound right? I know there's another issue regarding how to assign the lion/dog values (#108), but I'm just trying to picture the structure right now

klg-2016 commented 3 years ago

Kind of confused on how I'm going to make this--right now for yearlysitecovs, I input just the years (so a row with 2016 2017 2018 2019 for each camera) and get the following when I look at my umf image

yearlySiteCovs is a list [240x1] (S3:data.frame); A data frame with 240 rows and 1 column.

...all of which makes me think that the umf function converted my data frame with years into the appropriate format for the function (from a single row for each camera to the site-major, year-minor format we've discussed), but then I'm not sure how to approach it for more than one variable.

Does my question make sense?

klg-2016 commented 3 years ago

Linking this because it shows how someone else did multiple yearlysitecovs, from which I think I can figure it out

https://groups.google.com/g/unmarked/c/SxF-yAju2vw/m/kuRys2TaBAAJ

klg-2016 commented 3 years ago

It looks like I can use a single row for each site, with what I wrote before but across instead of down

So 2016 2017 2018 2019 "2016 lion" "2017 lion" "2018 lion" "2019 lion" "2016 dog" "2017 dog" "2018 dog" "2019 dog" repeated for each camera and then making it a list formats it appropriately

kaitlyngaynor commented 3 years ago

Have you figured this one out? let me know if you want eyes on anything

klg-2016 commented 3 years ago

I believe my most recent thinking should work, but I paused while thinking more about the data itself. I'll let you know how it goes when I actually try to implement this formatting.