Digging into your data

All the functionality of the morts package is accessible with the residences(), morts(), infrequent(), mortsplot(), and review() functions, addressed in the other vignettes. Many of these functions rely on output from additional functions. As you are exploring your data, you may want to run these additional functions to better dig through and understand your data. The drift() and season() functions are respectively addressed in the Drift and Seasonality vignettes. Here, we address the stationchange(), resmax(), and resmaxcml() functions.

stationchange() function

The thresholds in morts() rely on identifying the most recent station or location change of each animal, because it is assumed that the animal was alive before this most recent movement. To explore the most recent station changes for each animal, the user can can call stationchange() directly. The arguments are used in the same manner as for morts(). Drift may also be applied with the argument drift=TRUE. See the Drift vignette 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 of stationchange() is a dataframe with one row 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() function

The threshold for morts() when method is “last”, “any”, or “all” is determined by identifying the longest residence event that occurred before a station change. If there are some animals with very long resident events that are not identified as potential mortalities by morts(), you may want to look at the longest living residence events to explore how the threshold is being identified. This can be done by calling the resmax() function directly.

Note that stationchange() must be run beforehand, and the output provided in the argument stnchange.

If drift was applied in generating the residence events, the drift argument specifies whether drift events should be included in resmax(). If drift was not applied or if drift="morts" in morts(), then you should include drift=FALSE. If drift="threshold" or drift="both" in morts(), then you should include drift=TRUE. See the Drift vignette for more information on applying drift.

The output of resmax() is a dataframe with one row for each animal ID. The residence event information is for the event that has the longest duration and occurred before the most recent station change 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() function

The threshold for morts() when the method is “cumulative” or “any” is determined by finding the longest cumulative residence event that occurred before a station change. Cumulative residence events are the length of time between when an animal was first detected at a station and when it was last detected at the same station, ignoring any gaps in detection. You may wish to explore the cumulative residence events that contribute to determining this threshold. This can be done by calling the resmaxcml() function directly.

Note that stationchange() must be run beforehand, and the output provided in the argument stnchange.

If you have applied drift by using drift="threshold" or drift="both" in morts(), then you should apply drift using the drift() function and use the output as the input for the data argument in resmaxcml(). See the Drift vignette 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 of resmaxcml() is similar to that from resmax(), except there is one row for each cumulative residence event (not just the longest event). This means that there may be 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