sum_data | R Documentation |
Calculate summary statistics from e-obs raw acceleration data. Statistical variables composition can be chosen at will. Read the Details for the necessary preparetions of the raw data.
sum.data(data , time , stats , windowstart = 1 , burstcount = NULL , x = NULL , y = NULL , z = NULL , IntDur = NA , ID = NA , behaviour = NULL)
data |
data.frame of raw acceleration e-obs data exported without subseconds (for necessary format see Details.) |
time |
column where the timestamps of each burst are stored - column name needs to be put in " " |
stats |
vector of statiscial variables that should be calculated (for possible input see Details) |
windowstart |
in case a sliding window is used within the bursts this parameter set the start of the window, can be used in a loop to shift the starting value of the window |
IntDur |
duration of a single burst in seconds(only needed when the weigthed mean should be calculated (functional but not advised)) |
burstcount |
expected number of measurments per burst per axis (needed for Fast Fourier Transformation), also necessary for the sliding window approach to define window length |
x, y, z |
column in which the acceleration measurments for the axis are stored - column name needs to be put in " " |
id |
ID the the focal animal (not needed for calculation) |
behaviour |
if the raw data set has a column containing behaviour labels it can be named here and the labels will be added to the output data frame. |
This function will prepare the raw data from an e-obs acceleration tag for the use with machine learning. When the data from the tag is extracted from the logger.bin file it has to be in the format without subseconds. Every row of data belonging to the same timestamp need to have the same value in the time column.
To avoide confuison were data for one time of the day is recorded on several day the columns of the date and time have to be combied in one column. The name of that cloumn has to be specified as the time argument in the function.
The coloumn corresponding to the x-,y-,and z-axis can be named at will. The coloumn names of every axis have to be specified. By default calculations for the y and z axis are disabled. In cases where there are 2 or 3 axes measured there names can be included. The predictors q, Pitch, and Roll are dependend on all three axes so they will not be calculated for data set with only or 2 axes. The cloumn names have to be put in quotes to be recognised.
The argument id will create an additional column with supporting information. This information can be left out if not needed or unknown.
The stats argument provides a handle to choose predictors that will be calculated for the model. Possible inputs are: "all" will calculate the folling summary statistics: "mean","sd","max","min","range","cov","cor", "meandiff","sddiff","mdocp","sdocp","Var","q","Pitch","Roll","Yaw","ICV","CV","Kurtosis", "Skewness","ODBA"
"mean" for the mean of each axis
"sd" for the standard deviation of each axis
"max" for the maximum value of each axis
"min" for the minimum value of each axis
"range" for the difference between the maximum and minimum value of each axis
"cov" for the covariance between two axes for each combination of axes
"cor" for the correlation between two axes for each combination of axes
"meandiff" for the mean of the difference between two axes for each combination of axes
"sddiff" for the standard devidation of the difference between two axes for each combination of axes
"mdocp" for the mean difference of continues points for each axis
"sdocp" for the standard devidation of the difference of continues points for each axis
"Var" for the variance (1/N) of x, y and z
"CV" for the coefficient of variation of x, y and z
"ICV" for the inverse coefficient of variation of x, y and z
"q" for the square root of the sum of squares of x, y and z
"Pitch" for rotation of up and down
"Roll" for the rotation from side to side
"Yaw" for the rotation in the horizonal plane
"Kurtosis" for the kurtosis of x, y and z
"Skewness" for the skewness of x, y and z
"ODBA" for the overall dynamic body acceleration for all 3 axes
"FFT" for adding the positive half of the fast fourier spectrum to the predictor set, if this is used a burstcount has to be provided with burstcount = ...
This function can be used for a sliding window approach. For this the function can be put in a loop with the windowstart parameter set to i. The burstcount parameter will set the size of the window. The summary statistics will be calculated seperatly for every window fragment.
The output will be a data.frame with the summary statistics for a single time stamp in one row.
The weighted mean was inspired by Anne Berger
Wanja Rast
acceleration <- data.frame(time = rep(seq(5),each=20) , x = runif(n = 100,min = 1900,max=2100) , y = runif(n = 100,min = 2100,max=2300) , z = runif(n = 100,min = 1800,max=2000)) sumstats <- sum.data(data=acceleration , time="time" , x="x" , y="y" , z="z" , stats=c("mean" , "sd" , "Var"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.