EWS_calc | R Documentation |
Run the Early Warning Signals calculations and return a data frame with the sum of dynamic complexity, the cumulative complexity peaks and the corresponding user_id and dates.
EWS_calc(df)
df |
A data frame with the features of interest, a |
plot_pre |
A boolean value indicating whether the preprocessing steps should be plotted. |
This function assumes the data frame df
that is passed is data from one user ONLY
as this method is an individual based approach. To run this function across multiple users
see the examples section. Furthermore, for the dynamic complexity functions that run inside
this function there are parameters which are hard coded.
These include:
1. the window size (here the window is set to 28 due to the slow changing nature of MS)
2. the scale minimum (here it is 0 because the inputted data should be scaled between 0 and 1)
3. the scale maximum (here it is 1 because the inputted data should be scaled between 0 and 1)
4. the item alpha (here it is set to 0.001 as we are only interested in very large change to be visualized)
5. the time alpha (here it is set to 0.001 as we are only interested in very large change to be visualized)
A data frame with the sum of dynamic complexity, the cumulative complexity peaks and the corresponding user_id
and Timestamp
columns.
The main functions used here are dc_win()
, dc_ccp()
and functions from the imputeTS
and mice
packages. dc_win()
, dc_ccp()
are functions created by Fred Hasselman and Merlijn Olfthof.
James Twose
Olthof, M., Hasselman, F., Strunk, G., van Rooij, M., Aas, B., Helmich, M. A., ... & Lichtwarck-Aschoff, A. (2020). Critical fluctuations as an early-warning signal for sudden gains and losses in patients receiving psychotherapy for mood disorders. Clinical Psychological Science, 8(1), 25-35.
Schiepek, G., & Strunk, G. (2010). The identification of critical fluctuations and phase transitions in short term and coarse-grained time series-a method for the real-time monitoring of human change processes. Biological cybernetics, 102(3), 197-207.
Schiepek, G. (2003). A Dynamic Systems Approach to Clinical Case Formulation. European Journal of Psychological Assessment, 19, 175-184.
Haken, H. & Schiepek, G. (2006, 2. Aufl. 2010). Synergetik in der Psychologie. Selbstorganisation verstehen und gestalten. Gottingen: Hogrefe.
## For a single user, with preprocessing steps plotted: EWS_calc(df=df, plot_pre=TRUE) ## For a single user, with preprocessing steps not plotted: EWS_calc(df=df, plot_pre=FALSE) ## For multiple users: library(parallel) mclapply(dfs_list, EWS_calc)