All the functionality of the morts package is accessible with theresidences(),morts(),infrequent(),mortsplot(), andreview() functions, addressed in the other vignettes. Manyof these functions rely on output from additional functions. As you areexploring your data, you may want to run these additional functions tobetter dig through and understand your data. Thedrift()andseason() functions are respectively addressed in theDriftandSeasonalityvignettes. Here, we address thestationchange(),resmax(), andresmaxcml() functions.
stationchange() functionThe thresholds inmorts() rely on identifying the mostrecent station or location change of each animal, because it is assumedthat the animal was alive before this most recent movement. To explorethe most recent station changes for each animal, the user can can callstationchange() directly. The arguments are used in thesame manner as formorts(). Drift may also be applied withthe argumentdrift=TRUE. See theDriftvignette for more information on the other drift arguments.
station_change<-stationchange(data=events,type="mort",ID="ID",station="Station.Name",drift=TRUE,ddd=ddd,units="days",from.station="From",to.station="To")The output ofstationchange() is a dataframe with onerow for each animal ID. The residence event information (start, end,duration) is for the event that marks the most recent station change(i.e., the start is when the movement occurred).
| ResidenceStart | Station.Name | ID | ResidenceEnd | ResidenceLength.days |
|---|---|---|---|---|
| 2005-06-25 21:26:12 | 10 | A | 2005-06-26 09:01:17 | 0.4826968 |
| 2005-07-01 05:28:31 | 1 | B | 2005-07-01 05:28:31 | 0.0000000 |
| 2004-06-19 15:31:47 | 9 | C | 2004-06-19 19:10:01 | 0.1515509 |
| 2004-08-31 16:48:00 | 5 | D | 2004-08-31 17:38:18 | 0.0349306 |
| 2004-07-15 21:09:22 | 5 | E | 2004-10-12 21:44:11 | 89.0241782 |
| 2005-06-28 21:12:58 | 1 | F | 2005-10-09 20:28:05 | 102.9688310 |
resmax() functionThe threshold formorts() whenmethod is“last”, “any”, or “all” is determined by identifying the longestresidence event that occurred before a station change. If there are someanimals with very long resident events that are not identified aspotential mortalities bymorts(), you may want to look atthe longest living residence events to explore how the threshold isbeing identified. This can be done by calling theresmax()function directly.
Note thatstationchange() must be run beforehand, andthe output provided in the argumentstnchange.
If drift was applied in generating the residence events, thedrift argument specifies whether drift events should beincluded inresmax(). If drift was not applied or ifdrift="morts" inmorts(), then you shouldincludedrift=FALSE. Ifdrift="threshold" ordrift="both" inmorts(), then you shouldincludedrift=TRUE. See theDriftvignette for more information on applying drift.
The output ofresmax() is a dataframe with one row foreach animal ID. The residence event information is for the event thathas the longest duration and occurred before the most recent stationchange for that animal.
resmax_example<-resmax(data=events,ID="ID",station="Station.Name",res.start="ResidenceStart",residences="ResidenceLength.days",stnchange=station_change,drift=FALSE)| ResidenceStart | Station.Name | ID | ResidenceEnd | ResidenceLength.days |
|---|---|---|---|---|
| 2003-09-24 16:56:36 | 1 | A | 2003-10-11 17:15:47 | 17.0133218 |
| 2003-09-13 13:25:38 | 4 | C | 2003-10-07 16:26:06 | 24.1253241 |
| 2003-08-16 22:35:23 | 1 | G | 2003-08-18 12:05:20 | 1.5624653 |
| 2003-01-31 19:47:16 | 8 | I | 2003-02-06 18:59:34 | 5.9668750 |
| 2002-08-26 07:18:12 | 8 | J | 2002-08-26 22:01:00 | 0.6130556 |
| 2003-01-16 18:55:12 | 8 | K | 2003-02-08 16:31:25 | 22.9001505 |
resmaxcml() functionThe threshold formorts() when themethodis “cumulative” or “any” is determined by finding the longest cumulativeresidence event that occurred before a station change. Cumulativeresidence events are the length of time between when an animal was firstdetected at a station and when it was last detected at the same station,ignoring any gaps in detection. You may wish to explore the cumulativeresidence events that contribute to determining this threshold. This canbe done by calling theresmaxcml() function directly.
Note thatstationchange() must be run beforehand, andthe output provided in the argumentstnchange.
If you have applied drift by usingdrift="threshold" ordrift="both" inmorts(), then you should applydrift using thedrift() function and use the output as theinput for thedata argument inresmaxcml().See theDriftvignette for more information on applying drift.
resmaxcml_example<-resmaxcml(data=events,ID="ID",station="Station.Name",res.start="ResidenceStart",res.end="ResidenceEnd",residences="ResidenceLength.days",units="days",stnchange=station_change)The output ofresmaxcml() is similar to that fromresmax(), except there is one row for each cumulativeresidence event (not just the longest event). This means that there maybe more than one row for each animal ID.
| ResidenceStart | Station.Name | ID | ResidenceEnd | ResidenceLength.days |
|---|---|---|---|---|
| 2003-09-21 23:49:45 | 11 | A | 2003-09-22 00:08:18 | 0.0128819 days |
| 2003-09-22 00:20:28 | 1 | A | 2004-06-24 01:15:25 | 276.0381597 days |
| 2004-06-24 17:30:42 | 14 | A | 2004-06-24 17:30:42 | 0.0000000 days |
| 2004-06-24 20:37:18 | 8 | A | 2004-06-24 21:39:34 | 0.0432407 days |
| 2004-06-25 05:48:34 | 2 | A | 2004-06-25 06:47:40 | 0.0410417 days |
| 2004-06-26 04:49:31 | 10 | A | 2004-07-01 07:41:36 | 5.1195023 days |