write_byperson {suddengains} | R Documentation |
Write a sudden gains data frame (byperson) to CSV, SPSS, STATA or Excel files
Description
Writes a data frame as a specified file type.
Usage
write_byperson(
data,
sg_crit1_cutoff,
id_var_name,
sg_var_list,
tx_start_var_name,
tx_end_var_name,
sg_measure_name,
sg_crit2_pct = 0.25,
sg_crit3 = TRUE,
sg_crit3_alpha = 0.05,
sg_crit3_adjust = TRUE,
sg_crit3_critical_value = 2.776,
identify = c("sg", "sl"),
identify_sg_1to2 = FALSE,
multiple_sg_select = c("first", "last", "smallest", "largest"),
data_is_bysg = FALSE,
format = c("CSV", "SPSS", "STATA", "Excel"),
path,
stata_version = 14,
...
)
Arguments
data |
A data set in wide format including an ID variable and variables for each measurement point. |
sg_crit1_cutoff |
Numeric, specifying the cut-off value to be used for the first sudden gains criterion.
The function |
id_var_name |
String, specifying the name of the ID variable. Each row should have a unique value. |
sg_var_list |
Vector, specifying the variable names of each measurement point sequentially. |
tx_start_var_name |
String, specifying the variable name of the first measurement point of the intervention. |
tx_end_var_name |
String, specifying the variable name of the last measurement point of the intervention. |
sg_measure_name |
String, specifying the name of the measure used to identify sudden gains/losses. |
sg_crit2_pct |
Numeric, specifying the percentage change to be used for the second sudden gains/losses criterion.
If set to |
sg_crit3 |
If set to |
sg_crit3_alpha |
Numeric, alpha for the student t-test (two-tailed) to determine the critical value to be used for the third criterion. Degrees of freedom are based on the number of available data in the three sessions preceding the gain and the three sessions following the gain. |
sg_crit3_adjust |
Logical, specify whether critical value gets adjusted for missingness, see Lutz et al. (2013) and the documentation of this R package for further details.
This argument is set to |
sg_crit3_critical_value |
Numeric, specifying the critical value to instead be used for all comparisons, regardless of missingnes in the sequence of data points that are investigated for potential sudden gains.#' |
identify |
String, specifying whether to identify sudden gains ( |
identify_sg_1to2 |
Logical, indicating whether to identify sudden losses from measurement point 1 to 2. |
multiple_sg_select |
String, specifying which sudden gain/loss to select for this data set if more than one gain/loss was identified per case.
Options are: |
data_is_bysg |
Logical, specifying whether the data set in the |
format |
String, specifying the format of the data file, |
path |
String, specifying the file name ending with the matching file extension,
|
stata_version |
Numeric, specifying STATA version number. |
... |
Additional parameters to be passed on to the specified write function,
see |
Value
A csv file containing a wide data set with one row per case (id_var_name
) in data
.
References
Tang, T. Z., & DeRubeis, R. J. (1999). Sudden gains and critical sessions in cognitive-behavioral therapy for depression. Journal of Consulting and Clinical Psychology, 67(6), 894–904. doi:10.1037/0022-006X.67.6.894.
Examples
# Adjust "path" argument before running
# Create character string name for temporary "byperson.csv" file
temp <- tempfile(pattern = "byperson", fileext = ".csv")
# Write byperson dataset (CSV file)
# To write a different format change the 'format' argument ...
# ... as well as the file extension in the 'path' argument
write_byperson(data = sgdata,
sg_crit1_cutoff = 7,
id_var_name = "id",
tx_start_var_name = "bdi_s1",
tx_end_var_name = "bdi_s12",
sg_var_list = c("bdi_s1", "bdi_s2", "bdi_s3", "bdi_s4",
"bdi_s5", "bdi_s6", "bdi_s7", "bdi_s8",
"bdi_s9", "bdi_s10", "bdi_s11", "bdi_s12"),
sg_measure_name = "bdi",
identify_sg_1to2 = FALSE,
multiple_sg_select = "largest",
format = "CSV",
path = temp)