Identify sudden gains based on the criteria outlined by Tang and DeRubeis (1999). It applies all three criteria to a dataset while adjusting for missing values. It calculates further variables that are of interest. It handles multiple gains by creating two datasets, one structured by sudden gain and one by participant. It also implements a function to specify which sudden gains to choose in case of multiple gains (e.g. the earliest or largest gain).

To learn more about the background of this package see our preprint on PsyArXiv. We have also created an open Zotero group collecting all the literature looking at sudden gains in psychological therapies. Please let me know if I missed anything or join the group and add papers yourself.

Installation

You can install the released version of suddengains from CRAN with:

install.packages("suddengains")

And the development version from GitHub with:

Overview of the functions

The suddengains package comes with a range of features which can be categorised into:

  1. Functions to identify sudden gains:
  1. Functions to create datasets for further analysis:
  1. Helper functions to visualise and report sudden gains:
  1. Helper functions to export data sets to SPSS, Excel, Stata, and CSV:
  • write_bysg(): Exports CSV, SPSS, Excel, or STATA files of the sudden gains data sets
  • write_byperson(): Exports CSV, SPSS, Excel, or STATA files of the sudden gains data sets

A detailed illustration of all functions can be found in the vignette on CRAN. Note that the vignette is only available in R when you install the package from CRAN.

Examples

Below are some examples illustrating the suddengains package. More details can be found in the Vignette or on PsyArXiv.

1. Functions to identify sudden gains

To identify sudden gains/losses you can use the identify_sg() and identify_sl() functions. These functions return a data frame with new variables indicating for each between-session interval whether a sudden gain/loss was identified. For example the variable sg_2to3 holds information whether a sudden gains occurred from session two to three, with two being the pregain and three being the postgain session. Further functions to help with identifying sudden gains are listed above.

2. Functions to create datasets for further analysis

As participants may experience more than one gain, as in the present example, and to allow for different subsequent analyses, the package provides two options for output datasets: The create_bysg() function creates a dataset structured with one row per sudden gain, and the create_byperson() function creates a dataset structured with one row per person, indicating whether or not they experienced a sudden gain. The create_bysg() function is shown below. More functions to help with creating datasets for further analyses are listed above.

3. Helper functions to visualise and report sudden gains

The plot_sg() function plots the ‘average’ sudden gain, and can be used to show changes around the sudden gain. The plot_sg_trajectories() can be used to visualise trajectories for a selection of individual cases.