This script analysises various aspects of the sociocultural context in a nursing home:
- Patients activity, sleep and proximity to other patients and nurses
- Nurses activity and proximity to patients
The data collection is done by equipping patients, patients' bed and nurses with Estimote Stickers which broadcast Nearable packets (containing RSSI, accelerometer, UUID). These packets are received and parced by automation units which runs an app built using the Estimote SDK.
Start by declaring the following variables:
- Directories for location of the data, scripts, output and models.
- Declare vectors patients_all and nurses_all which contains the alias of all users.
- Declare the named vector nearables which links the alias with the UUID of the sensors for all the users.
- Repeat for automation units
The user only needs to run the main_script.R which will source() the scripts needed for analysis. An error message might indicate that the user need to install the required libraries used in each script. The main_script.R expects .Rdata files to be located at the path of the data_dir variable. Each .Rdata file contains a data frame (named df_combined) with data for 1 day (from 06.30 in the morning, until 06.29 the next day e.g., 2017-08-24 06:30:00 EEST to 2017-08-25 06:29:59 EEST). The structure of the data is shown in the figures below.
The script loops through each .Rdata file and outputs a .Rdata file containing the result for each analysis. To use the script for real time computations, the for loop should be replaced with a daily db query that retrieves the data for that particular day. The user needs to build the following models before running the main_script.R:
Geofence model
The facility which the data is collected from should be divided into N geofences. RSSI values can then be collected from each geofence to form the training set shown below. A classification model can then be trained from this data.
Bed models
A script is also included to create the bed models for in-bed prediction.