# 4.1) Processes behind residency()

## Index

Note:
The processes behind multi-way efficiency estimations are explained in this manual page.

## Section movements

The initial processes of residency() are the same as those from the explore() function.

Upon validating the movement events, the residency analysis proceeds to compressing these array-level events into section-level events. You can find an example here. This shows how many times a tag entered and left each section. It is here that the argument section.minimum comes in. If the number of consecutive detections at a given section are lower than the value stipulated, a warning will be issued, and user interaction is suggested:

M: Section movements with less than 2 detections are present for tag R64K-3.
Would you like to inspect the section movements from tag R64K-3?(y/N/comment)

You can then decide whether or not something should be considered invalid. Once all tags have been validated, if any section movement has been deemed invalid, the respective array movements will also be invalidated. Actel will let you know this happened by issuing a message:

M: Rendering 1 array movement(s) invalid for tag R64K-3 as the respective section movements were discarded by the user.

## Residency lists

Once the section movements have been validated, actel fills in the gaps between movements using the departure timestamp of a given section and the arrival timestamp of the next. These middle locations are labelled using both sections’ names, separated with a dash (e.g. Down-Right). You can find an example here.

## Compiling a timetable

Using the residency table above, actel compiles a summary timetable containing the following information for each section: number of times the tag entered the section, average entry time, average time spent per stay, average departure time and total time spent in the section. A few more summary columns are added to this table before it is bound to the information provided in the biometrics table.

## Daily/Hourly locations

Based on the table above, actel will proceed to calculate the amount of time spent per day (or hour, if timestep = "hours") at each location (in seconds). This leads to a very long table displaying both the number of seconds spent per day/hour at each location, as well as the respective percentages. It also contains an additional column showing the location where the tags spent the most time each day/hour. You can find an example here.

## Global ratios

Using the table above as a reference for each tag, actel is then able to calculate how many of your animals were at each location during each passing day/hour. Actel calculates two similar tables, one with absolute numbers, and one with percentages. You can find an example here.

## Wrapping up

After all this information has been compiled and stored, actel will wrap up by collecting the valid detections and storing them in the valid.detections object, which you can then use for other analyses. One last table is also stored containing a summary of the place of last detection for each animal group.