pyActigraphy.metrics.MetricsMixin.pRA

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

Rest->Activity transition probability distribution

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

\[pRA(t) = p(A|R_t) = \frac{N_t - N_{t+1}}{N_t}\]

with \(N_t\), the total number of sequences of rest (i.e. activity below 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 pRA. Default is None.

Returns

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

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

Notes

pRA 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')
>>> pRA, pRA_weights = rawAWD.pRA(4, start='00:00:00', period='8H')
>>> pRA
counts
1      0.169043
2      0.144608
3      0.163324
(...)
481    0.001157
Name: counts, dtype: float64