
Score a TOCS-2 Questionnaire
Source:vignettes/articles/score_a_tocs_questionnaire.Rmd
score_a_tocs_questionnaire.RmdThe Toronto Obsessive-Compulsive Scale 2 (TOCS-2) is a validated instrument for measuring Obsessive-Compulsive (OCD) traits. This article shows you how to score your TOCS-2 tests.
Quick Start
The code below shows how to score a TOCS-2 questionnaire using the
score_tocs2() function.
library(sfsScorer)
#> sfsScorer Copyright (C) 2026 Jonathan Clutton
#> This program comes with ABSOLUTELY NO WARRANTY
#> This is free software, and you are welcome to redistribute it under certain
#> conditions
#> See conditions: <https://jclutton.github.io/sfsScorer/LICENSE.html>
#' Here's how we expect the data to be formatted
#' age (5-18)
#' gender
#' for non-gendered t-scores (Any gender values are acceptable)
#' for gendered t-scores (1 = boy, 2 = girl)
#' p_respondent (1 = parent / caregiver responded, 0 = child / youth respondent)
#' All tocs questions 1-24 as tocs1...tocs24
head(random_data, 1)
#> age gender p_respondent tocs1 tocs2 tocs3 tocs4 tocs5 tocs6 tocs7 tocs8 tocs9
#> 1 14 2 1 -1 2 -2 0 3 -1 0 1 2
#> tocs10 tocs11 tocs12 tocs13 tocs14 tocs15 tocs16 tocs17 tocs18 tocs19 tocs20
#> 1 2 0 -2 2 -1 -1 2 0 -2 -2 2
#> tocs21 tocs22 tocs23 tocs24
#> 1 1 -2 3 -3
# Score from a data frame
scores <- score_tocs2(df = random_data)
#> ✔ The model scored 5 observations.
# OR
# Score from a a csv or xlsx file
tocs_csv <- system.file("extdata", "sample_tocs.csv", package = "sfsScorer")
scores_csv <- score_tocs2(file = tocs_csv)
#> ✔ The model scored 5 observations.
# Data are validated by default
df_mod <- random_data |>
dplyr::mutate(tocs1 = 6)
try(scores_csv <- score_tocs2(df = df_mod))
#> There are 5 impossible values in the file.
#> The only valid values are -3, -2, -1, 0, 1, 2, 3, and NA.
#>
#> Error in clean_file(df, test = "tocs", ignore_check = ignore_check) :
#> Please correct or remove these rows - "Row 1: tocs1 - 6", "Row 2: tocs1
#> - 6", "Row 3: tocs1 - 6", "Row 4: tocs1 - 6", and "Row 5: tocs1 - 6"
# To ignore validation and introduce NAs use `ignore_check = TRUE`.
# This can impact scoring
scores_csv <- score_tocs2(df = df_mod, ignore_check = TRUE)
#> ! 5 impossible values were changed to NA. This could impact scores.
#> The only valid values are -3, -2, -1, 0, 1, 2, 3, and NA. To correct, review the following rows before running - "Row 1: tocs1 - 6", "Row 2: tocs1 - 6", "Row 3: tocs1 - 6", "Row 4: tocs1 - 6", and "Row 5: tocs1 - 6"
#> ✔ The model scored 0 observations.
#> ! 5 observations were not scored due to excessive missingness. 0 questions are allowed to be missing.
# Allow more missingness
# This will use prorated scores
scores_csv <- score_tocs2(df = df_mod, ignore_check = TRUE, max_missing = 1)
#> ! 5 impossible values were changed to NA. This could impact scores.
#> The only valid values are -3, -2, -1, 0, 1, 2, 3, and NA. To correct, review the following rows before running - "Row 1: tocs1 - 6", "Row 2: tocs1 - 6", "Row 3: tocs1 - 6", "Row 4: tocs1 - 6", and "Row 5: tocs1 - 6"
#> ✔ The model scored 5 observations.Notes Before Starting
- T-scores will be generated based on gendered and non-gendered norms. Please feel free to include children who are trans or non-binary in your dataset and leave the codes for their gender as appropriate for the individuals in your study. Non-gendered t-scores will be generated for all individuals. Gendered t-scores will only be generated when gender is coded as 1 or 2. It is recommended to use the non-gendered t-scores for trans or non-binary individuals.
Instructions
Formatting Your Data
Our first step is to prepare your raw TOCS-2 data.
Prepare a spreadsheet, preferably a .csv file, with a row for each of the tests you’d like to score.
-
Be sure the following columns are present in the spreadsheet and rename the columns to match the reference guide below. All of the following columns are necessary for the model. If age or p_respondent are missing from a row, the model will not return a t-score for that row.
Column Name Additional Information Example age The child’s age 5 - 18
Note: Age in a numeric form, i.e. with decimals, will provide a more accurate t-score compared to an integer-based agegender The child’s gender.
- A full range of gender options can be included with the questionnaire.
- If you want to generate non-gendered norms, any gender identities can be included and coded in any way (e.g., boy, girl, transgender, non-binary, etc).
- If you want to generate gendered norms, gender must be binary and coded as 1 = boy and 2 = girlNon-gendered t-scores: any value
Gendered t-scores: 1 = Boy, 2 = Girl
Note: Any gender not coded as 1 or 2 will not receive a gendered t-score.p_respondent Whether the survey was filled out by the parent or the child 1 = Parent / Caregiver Respondent, 0 = Child / Youth Self-Respondent tocs1 TOCS-2 Question #1 -3 (Far Below) to 3 (Far Above) tocs2 TOCS-2 Question #2 -3 (Far Below) to 3 (Far Above) tocs3 TOCS-2 Question #3 -3 (Far Below) to 3 (Far Above) tocs4 TOCS-2 Question #4 -3 (Far Below) to 3 (Far Above) tocs5 TOCS-2 Question #5 -3 (Far Below) to 3 (Far Above) tocs6 TOCS-2 Question #6 -3 (Far Below) to 3 (Far Above) tocs7 TOCS-2 Question #7 -3 (Far Below) to 3 (Far Above) tocs8 TOCS-2 Question #8 -3 (Far Below) to 3 (Far Above) tocs9 TOCS-2 Question #9 -3 (Far Below) to 3 (Far Above) tocs10 TOCS-2 Question #10 -3 (Far Below) to 3 (Far Above) tocs11 TOCS-2 Question #11 -3 (Far Below) to 3 (Far Above) tocs12 TOCS-2 Question #12 -3 (Far Below) to 3 (Far Above) tocs13 TOCS-2 Question #13 -3 (Far Below) to 3 (Far Above) tocs14 TOCS-2 Question #14 -3 (Far Below) to 3 (Far Above) tocs15 TOCS-2 Question #15 -3 (Far Below) to 3 (Far Above) tocs16 TOCS-2 Question #16 -3 (Far Below) to 3 (Far Above) tocs17 TOCS-2 Question #17 -3 (Far Below) to 3 (Far Above) tocs18 TOCS-2 Question #18 -3 (Far Below) to 3 (Far Above) tocs19 TOCS-2 Question #19 -3 (Far Below) to 3 (Far Above) tocs20 TOCS-2 Question #20 -3 (Far Below) to 3 (Far Above) tocs21 TOCS-2 Question #21 -3 (Far Below) to 3 (Far Above) tocs22 TOCS-2 Question #22 -3 (Far Below) to 3 (Far Above) tocs23 TOCS-2 Question #23 -3 (Far Below) to 3 (Far Above) tocs24 TOCS-2 Question #24 -3 (Far Below) to 3 (Far Above)
Generate Scores
Use the code below to generate your t-scores. First, you will be prompted to select your file. Second, we will check that your data are formatted properly. Third, t-scores will be generated.
If you receive an error, please correct the issue in your file, save
your file, then run the score_tocs2() function again.
library(sfsScorer)
# The score_tocs2 function checks that your data are formatted correctly and generates the t-scores
tocs <- score_tocs2()Additional options
You have the option to…
# Score from a data.frame in case the data do not exist in a csv file
tocs <- score_tocs2(df = tocs)
# Specify the input file
tocs <- score_tocs2(file = here("test_scores.csv"))
# Export results to an output folder
tocs <- score_tocs2(output_folder = file.path("C:","Users",..."yourpath"))
# Change the number of allowed missingness.
# Default missinness is 0 questions. You can use the max_missing variable to allow more missingness
# Doing so will use a prorated score to generate a t-score. This can produce outliers and issues
tocs <- score_tocs2(file = here("test_scores.csv"), max_missing = 2)