R/IS.R

Defines functions IS

Documented in IS

#' @title Interdaily Statbility
#' @description This function calcualte interdaily stability, a nonparametric metric
#' of circadian rhtymicity
#'
#' @param x  \code{data.frame} of dimension ndays by p, where p is the dimension of the data.
#'
#' @references Junrui Di et al. Joint and individual representation of domains of physical activity, sleep, and circadian rhythmicity. Statistics in Biosciences.
#' @export
#'
#'
#' @examples
#' data(example_activity_data)
#' count1 = example_activity_data$count[c(1,2,3),-c(1,2)]
#' is = IS(x = count1)


IS = function(
  x
  ){
  p = ncol(x)
  xh = colMeans(x)

  v = c(t(x))
  n = length(v)

  numerator = sum((xh - mean(v))^2)/p
  denominator = sum((v - mean(v))^2)/n

  return(numerator/denominator)
}

Try the ActCR package in your browser

Any scripts or data that you put into this service are public.

ActCR documentation built on May 11, 2022, 5:13 p.m.