pyActigraphy.metrics.MetricsMixin.pAR

MetricsMixin.pAR(threshold, start=None, period=None)[source]

Activity->Rest transition probability distribution

Conditional probability, pAR(t), that an individual would be active at time (t+1) given that the individual had been continuously resting for the preceding t epochs, defined in [1] as:

\[pAR(t) = p(R|A_t) = \frac{N_t - N_{t+1}}{N_t}\]

with \(N_t\), the total number of sequences of activity (i.e. activity above threshold) of duration \(t\) or longer.

Parameters
  • threshold (int) – If binarize is set to True, data above this threshold are set to 1 and to 0 otherwise.

  • start (str, optional) – If not None, the actigraphy recording is truncated to ‘start:start+period’, each day. Start string format: ‘HH:MM:SS’. Default is None

  • period (str, optional) – Time period for the calculation of pAR. Default is None.

Returns

  • par (pandas.core.series.Series) – Transition probabilities (pAR(t)), calculated for all t values.

  • par_weights (pandas.core.series.Series) – Weights are defined as the square root of the number of activity sequences contributing to each probability estimate.

Notes

pAR is corrected for discontinuities due to sparse data, as defined in [1].

References

1(1,2)

Lim, A. S. P., Yu, L., Costa, M. D., Buchman, A. S., Bennett, D. A., Leurgans, S. E., & Saper, C. B. (2011). Quantification of the Fragmentation of Rest-Activity Patterns in Elderly Individuals Using a State Transition Analysis. Sleep, 34(11), 1569–1581. http://doi.org/10.5665/sleep.1400

Examples

>>> import pyActigraphy
>>> rawAWD = pyActigraphy.io.read_raw_awd(fpath + 'SUBJECT_01.AWD')
>>> pAR, pAR_weights = rawAWD.pAR(4, start='00:00:00', period='8H')
>>> pAR
counts
1      0.169043
2      0.144608
3      0.163324
(...)
481    0.001157
Name: counts, dtype: float64