Exercise on responsiveness with answers

Back to the main page

Responsiveness

The tab Exercise introduction explains the context and the datasets - please read it carefully. Then proceed to the Questions tab and answer the questions.

You are part of a cohort study looking at neck pain in primary sector (physiotherapy and chiropractic practice) and secondary sector patients (spinal outpatient clinic). The cohort study has collected data at baseline and 3 months follow-up on the Neck Disability Index (NDI). The 3 months follow-up also has a an external anchor (transition rating). You have decided to look at responsivenss of the Neck Disability Index (NDI).

The dataset

The exercise uses a dataset called ‘resp_data.rds’. The dataset contains an id number, where the patient is seen, an external anchor (transition question), and the change scores for the following questionnaires:

ALL SCORES OF THE INCLUDED QUESTIONNAIRES HAVE BEEN CONVERTED TO A 0-100 SCALE WITH HIGHER SCORES REPRESENTING A LOT OF THE CONSTRUCT AND LOWER SCORES A LITTLE OF THE CONSTRUCT.

The Neck Disability Index (NDI)

Click here to see it.

The Neck Disability Index (NDI) is a widely used questionnaire for assessing self-reported disability related to neck pain. It consists of 10 items that cover common areas of daily living affected by neck problems: pain intensity, personal care, lifting, reading, headaches, concentration, work, driving, sleeping, and recreation. The NDI provides an overall indication of how neck pain influences both daily activities and general quality of life.

The Copenhagen Neck Function Disability Score (CNFDS)

Click here to see it

The Copenhagen Neck Functional Disability Scale (CNFDS) is designed to capture both the functional impact of neck problems and the pain dimension separately.

cnfds_d_change (CNFDS-function, 15 items)
The function subscale includes items about everyday activities that may be affected by neck pain, such as sleeping, dressing, lifting, concentration, reading, leisure activities, and maintaining social contact. It provides a broad picture of how neck problems interfere with daily functioning, work, and social life.

cnfds_p_change (CNFDS-pain, 6 items)
The pain subscale focuses on the patient’s experience of pain in the neck and arms. It includes ratings of current pain, the worst pain in the past two weeks, and average pain during that same period. By covering both present and retrospective pain experience, the scale captures a wider view of pain intensity over time.

Compared to the NDI, the CNFDS provides a more detailed and multidimensional assessment that distinguishes between function and pain.

SF36 (version 1.0)

Click here to see it

The 8 subscales

sf_pf_change (physical functioning, 10 items)
Assesses what a person can do physically in daily life. It focuses on the ability to perform activities such as walking, climbing stairs, carrying groceries, or dressing and bathing. This is about capacity for physical tasks.

sf_rp_change (role physical, 4 items)
Looks at how physical health problems interfere with daily roles such as work or household duties. It is not about what activities a person is physically able to do, but whether illness or physical limitations cause them to reduce time, limit the type of tasks, or lower work performance.

sf_bp_change (bodily pain, 2 items)
Evaluates both the intensity of bodily pain and the degree to which pain interferes with normal work, including activities at home and outside the home.

sf_gh_change (general health, 5 items)
Captures perceptions of personal health, including evaluations of current health status, overall health compared to the past, expectations for future health, and general susceptibility to illness.

sf_vt_change (vitality, 4 items)
Assesses how energetic or tired a person feels in daily life. Items ask about feeling full of life and energetic, as well as feeling tired or worn out.

sf_mh_change (mental health, 5 items)
Measures general mental well-being. It includes emotional states themselves — both negative (e.g., anxiety, sadness, nervousness) and positive (e.g., calmness, peacefulness, happiness).

sf_re_change (role emotional, 3 items)
Examines how emotional problems interfere with daily roles. It focuses on the impact of difficulties such as depression or anxiety on work and daily activities — e.g., doing less, spending less time, or accomplishing less because of emotional issues.

sf_sf_change (social functioning)
Examines the degree to which health interferes with normal social activities, such as interactions with family, friends, or participation in social groups.

The two summary components

pcs_change (Physical Component Summary (PCS))
A composite score that primarily reflects physical health. It is calculated from the subscales:

  • Physical Functioning (PF)
  • Role Physical (RP)
  • Bodily Pain (BP)
  • General Health (GH)

mcs_change (Mental Component Summary (MCS))
A composite score that primarily reflects mental health. It is calculated from the subscales:

  • Vitality (VT)
  • Mental Health (MH)
  • Role Emotional (RE)
  • Social Functioning (SF)

Numeric Rating Scale (NRS) for pain

Click here to see it

The Numeric Rating Scale (NRS) for average pain consists of a single item where the respondent is asked to rate the average intensity of their pain over a given time period, often the past 24 hours or the past week. The response is given on an 11-point scale ranging from 0, representing “no pain,” to 10, representing “worst imaginable pain.” This measure provides a simple and practical way to capture perceived pain intensity.

Global Perceived Effect (GPE) scale

Click here to see it

A Global Perceived Effect (GPE) scale (external anchor) was included at 3 months follow-up. The question was:

How would you describe your general neck/arm problems now, compared now to how you were when the treatment started?

  • Much improved
  • Improved
  • Slightly improved
  • No change
  • Slightly worse
  • Worse
  • Much worse

The dataset is summarised below:

Code
# Showing a summary of the dataset
(summary <- skim(resp_data))
Data summary
Name resp_data
Number of rows 326
Number of columns 17
_______________________
Column type frequency:
numeric 17
________________________
Group variables None

Variable type: numeric

skim_variable n_missing complete_rate mean sd p0 p25 p50 p75 p100 hist
idnr 0 1.00 510.10 217.30 101.00 319.25 613.50 694.75 776.00 ▃▂▂▃▇
seen 0 1.00 1.54 0.50 1.00 1.00 2.00 2.00 2.00 ▇▁▁▁▇
ndi10_change 88 0.73 -13.36 19.05 -87.11 -22.50 -11.27 0.00 44.44 ▁▂▇▇▁
cnfds_d_change 107 0.67 -5.54 24.75 -90.00 -20.00 -3.33 6.67 63.33 ▁▂▇▅▁
cnfds_p_change 90 0.72 -15.05 18.41 -66.67 -26.67 -15.00 -3.33 45.00 ▁▆▇▃▁
sf_pf_change 91 0.72 -3.51 22.97 -95.00 -15.00 0.00 5.00 90.00 ▁▂▇▂▁
sf_rp_change 96 0.71 -8.22 42.50 -100.00 -25.00 0.00 25.00 100.00 ▂▅▇▅▁
sf_bp_change 90 0.72 -14.11 23.92 -90.00 -29.00 -11.00 0.00 59.00 ▁▃▇▆▁
sf_gh_change 95 0.71 -2.23 19.25 -77.00 -10.00 0.00 9.00 52.00 ▁▁▇▅▁
sf_vt_change 94 0.71 -6.76 18.95 -60.00 -15.00 -5.00 5.00 50.00 ▁▂▇▂▁
sf_mh_change 94 0.71 -1.74 16.59 -64.00 -12.00 0.00 8.00 44.00 ▁▁▇▃▁
sf_re_change 98 0.70 -10.31 47.83 -100.00 -33.33 0.00 0.00 100.00 ▃▂▇▂▂
sf_sf_change 90 0.72 -5.77 22.37 -75.00 -25.00 0.00 0.00 75.00 ▁▃▇▁▁
pcs_change 107 0.67 -2.58 8.96 -31.27 -7.60 -1.30 2.47 22.07 ▁▂▇▅▁
mcs_change 107 0.67 -2.05 10.15 -30.69 -7.67 -1.32 4.21 30.76 ▁▃▇▃▁
smagns_change 89 0.73 -0.98 2.02 -8.00 -2.00 0.00 0.00 4.00 ▁▂▇▇▂
anchor_g3 95 0.71 2.50 1.25 1.00 1.00 2.00 3.00 6.00 ▇▃▃▁▁

Start with the questions in tab ‘1. Construct responsiveness’ and, when finished, continue to the next.

Please write down your answers to the questions. The exercise including answers can be downloaded after the course as a html-document from the webpage.

First you look at construct responsiveness. In the exercise introduction you have a description of all the included instruments (and subscales).

Questions

1.1 The correlation ranges from 0 - 1. How would you tricotomize the correlation into ‘weak’, ‘moderate’, or ‘strong’?

ImportantAnswer

To classify the strength of correlations, we can use Cohen’s criteria (1). According to this framework, correlations are trichotomized as:

  • Weak correlation: r < 0.30
  • Moderate correlation: r between 0.30 and 0.50
  • Strong correlation: r > 0.50

This means that if two instruments measure the same construct (for example, two disability questionnaires), we would expect a strong correlation (> 0.50). If they measure related but not identical constructs (e.g., disability vs. pain), we would expect a moderate correlation (0.30–0.50). Finally, if they measure different constructs (e.g., disability vs. general health perception), only a weak correlation (< 0.30) would be expected.

By using Cohen’s criteria, we can make our hypotheses about responsiveness explicit and testable.

  1. Cohen J. Statistical Power Analysis for the Behavioral Sciences. 2nd ed. Hillsdale, NJ: Lawrence Erlbaum Associates; 1988

1.2 Formulate 7 hypotheses which can be tested in your dataset.

Each hypothesis should:

  • Be plausible but challenging (not trivial)
  • State the direction of the association (positive or negative)
  • Indicate the expected correlation strength (weak, moderate, strong, based on Cohen’s criteria*)
  • Provide a reason for expecting the relationship

You should formulate hypotheses of both convergent validity (instruments measuring the same or related constructs should correlate strongly) and divergent validity (instruments measuring different constructs should correlate weakly).

Specifically, include:

  • 2 hypotheses for the relationship between NDI and CNFDS
  • 4 hypotheses for the relationship between NDI and a subscale or summary component of the SF-36
  • 1 hypothesis for the relationship between NDI and the NRS for average pain

Write your hypotheses in clear sentences.

  • If you don’t know Cohen’s criteria ask ChatGPT, Perplexity or Copilot.
ImportantAnswer

Here are examples on how the hypotheses can be formulated:

NDI vs CNFDS (2 hypotheses)

We expect a strong positive correlation (>0.50) between the NDI total score and the CNFDS function subscale, because both questionnaires measure disability in everyday activities caused by neck problems.

We expect a moderate positive correlation (0.30–0.50) between the NDI total score and the CNFDS pain subscale, because pain is related to disability but represents a distinct construct from activity limitations.

NDI vs SF-36 (4 hypotheses)

We expect a strong positive correlation (>0.50) between the NDI total score and the SF-36 Physical Functioning subscale, because higher disability is closely related to lower physical function.

We expect a moderate positive correlation (0.30–0.50) between the NDI total score and the SF-36 Bodily Pain subscale, because pain is related to disability but does not fully overlap with functional limitations.

We expect a weak-to-moderate positive correlation (<0.30–0.50) between the NDI total score and the SF-36 Mental Health subscale, because neck-related disability may influence psychological well-being, but they measure different constructs.

We expect a strong positive correlation (>0.50) between the NDI total score and the SF-36 Physical Component Summary (PCS), because both capture physical aspects of health and functioning.

NDI vs NRS (1 hypothesis)

We expect a moderate positive correlation (0.30–0.50) between the NDI total score and the NRS for average pain, because pain intensity contributes to disability, but pain and disability are not identical constructs.

An overview of the hypotheses are provided in Table 1.

Code
hypotheses_tbl <- tribble(
  ~pair,                         ~direction,  ~expected_correlation, ~type,         ~hypothesis,
  "NDI vs CNFDS (function)",     "Positive",  "Strong (> 0.50)",     "Convergent",  "Both measure disability in everyday activities related to neck problems.",
  "NDI vs CNFDS (pain)",         "Positive",  "Moderate (0.30–0.50)","Convergent",  "Pain relates to disability but is a distinct construct from activity limitations.",
  "NDI vs SF-36 Physical Functioning (PF)", "Positive",  "Strong (> 0.50)",     "Convergent",  "Higher disability should accompany lower physical functioning.",
  "NDI vs SF-36 Bodily Pain (BP)","Positive", "Moderate (0.30–0.50)","Convergent",  "Pain and disability are related but not identical.",
  "NDI vs SF-36 Mental Health (MH)","Positive","Weak–Moderate (<0.30–0.50)","Divergent","Psychological well-being can be influenced by disability, but they tap different constructs.",
  "NDI vs SF-36 Physical Component Summary (PCS)","Positive","Strong (> 0.50)","Convergent","Both summarize physical health/function limitations.",
  "NDI vs NRS (average pain)",   "Positive",  "Moderate (0.30–0.50)","Convergent",  "Greater pain intensity is expected to accompany greater disability, without full overlap."
) |>
  mutate(
    hypothesis = str_replace_all(hypothesis, "\\s+", " ")
  )

gt(hypotheses_tbl) |>
  tab_header(title = "Table 1. Hypotheses for Construct Responsiveness") |>
  cols_label(
    pair = "Instrument Pair",
    direction = "Direction",
    expected_correlation = "Expected Correlation (Cohen)",
    type = "Convergent / Divergent",
    hypothesis = "Reasoning"
  ) |>
  cols_align(align = "left", columns = everything()) |>
  tab_options(
    heading.align = "left",
    table.font.size = "small",   # smaller font
    table.width = px(600)        # shrink table width
  )
Table 1. Hypotheses for Construct Responsiveness
Instrument Pair Direction Expected Correlation (Cohen) Convergent / Divergent Reasoning
NDI vs CNFDS (function) Positive Strong (> 0.50) Convergent Both measure disability in everyday activities related to neck problems.
NDI vs CNFDS (pain) Positive Moderate (0.30–0.50) Convergent Pain relates to disability but is a distinct construct from activity limitations.
NDI vs SF-36 Physical Functioning (PF) Positive Strong (> 0.50) Convergent Higher disability should accompany lower physical functioning.
NDI vs SF-36 Bodily Pain (BP) Positive Moderate (0.30–0.50) Convergent Pain and disability are related but not identical.
NDI vs SF-36 Mental Health (MH) Positive Weak–Moderate (<0.30–0.50) Divergent Psychological well-being can be influenced by disability, but they tap different constructs.
NDI vs SF-36 Physical Component Summary (PCS) Positive Strong (> 0.50) Convergent Both summarize physical health/function limitations.
NDI vs NRS (average pain) Positive Moderate (0.30–0.50) Convergent Greater pain intensity is expected to accompany greater disability, without full overlap.

1.3 How would you test each of your hypothesis?

ImportantAnswer

Each hypothesis can be tested by examining the correlation between change scores of the instruments (responsiveness analysis).

  • Step 1: Calculate the change score for each instrument (follow-up score – baseline score).
  • Step 2: Choose an appropriate correlation coefficient:
    • Since the data are not normally distributed and many instruments use ordinal response categories, use Spearman’s rank correlation.
  • Step 3: For each instrument pair, compute Spearman’s correlation coefficient (r).
  • Step 4: Compare the observed r with your predefined hypothesis (weak, moderate, strong) based on Cohen’s criteria (Cohen, 1988).
  • Step 5: Interpret whether the hypothesis was confirmed (direction and magnitude match prediction).

In summary:

All 7 hypotheses are tested the same way by computing Spearman’s correlation between change scores for the two instruments in each hypothesis.

The result is then compared with the expected correlation strength and direction.

The results are summarised in Table 2.

Code
# Defining hypotheses in tribble

hypotheses <- tribble(
  ~pair,                               ~y_var,             ~expected_band,           ~expected_sign,
  "NDI vs CNFDS (function)",           "cnfds_d_change",   "strong",                 "positive",
  "NDI vs CNFDS (pain)",               "cnfds_p_change",   "moderate",               "positive",
  "NDI vs SF-36 Physical Functioning", "sf_pf_change",     "strong",                 "positive", # set "negative" if preferred
  "NDI vs SF-36 Bodily Pain",          "sf_bp_change",     "moderate",               "positive", # set "negative" if preferred
  "NDI vs SF-36 Mental Health",        "sf_mh_change",     "moderate",               "positive", # set "negative" if preferred
  "NDI vs SF-36 PCS",                  "pcs_change",       "strong",                 "positive", # set "negative" if preferred
  "NDI vs NRS (average pain)",         "smagns_change",    "moderate",               "positive"
)

# Classification according to Cohens criteria
band_of <- function(r){
  a <- abs(r)
  dplyr::case_when(
    a < 0.30           ~ "weak",
    a >= 0.30 & a <= .50 ~ "moderate",
    a > 0.50           ~ "strong"
  )
}

# Looping all y_var from hypotheses and building a tibble
corr_res <- map_dfr(hypotheses$y_var, ~{
  v <- .x
  x <- resp_data$ndi10_change
  y <- resp_data[[v]]
  ok <- !(is.na(x) | is.na(y))
  ct <- suppressWarnings(cor.test(x[ok], y[ok], method = "spearman", exact = FALSE))
  tibble(y_var = v, n = sum(ok), rho = unname(ct$estimate), p_value = ct$p.value)
})

# Joining hypothesis and correlation results and checking if hypotheses are true or not
results <- hypotheses |>
  left_join(corr_res, by = "y_var") |>
  mutate(
    observed_band = band_of(rho),                          # classify observed correlation
    observed_sign = if_else(rho >= 0, "positive", "negative"),
    band_match    = observed_band == expected_band,        # direct comparison only
    sign_match    = observed_sign == expected_sign,
    hypothesis_met = band_match & sign_match
  ) |>
  select(pair, y_var, n, rho, observed_sign, observed_band,
         expected_sign, expected_band, band_match, sign_match, hypothesis_met)

# Generating a gt-table

results |>
  mutate(
    rho = round(rho, 2),                          
    "Band match"     = if_else(band_match,  "✔", "✖"),
    `Sign match`     = if_else(sign_match,  "✔", "✖"),
    `Hypothesis met` = if_else(hypothesis_met, "✔", "✖"),
    `Observed band`  = observed_band,
    `Observed sign`  = observed_sign,
    `Expected band`  = expected_band,
    `Expected sign`  = expected_sign
  ) |>
  select(
    pair, n, rho,
    `Observed sign`, `Observed band`,
    `Expected sign`, `Expected band`,
    `Band match`, `Sign match`, `Hypothesis met`
  ) |>
  gt() |>
  tab_header(title = "Table 2. Construct Responsiveness of NDI") |>
  cols_label(
    pair = "Instrument Pair",
    n = "N",
    rho = "Spearman ρ"
  ) |>
  fmt_number(columns = c(rho), decimals = 2) |>
  data_color(
    columns = "Observed band",
    fn = scales::col_factor(
      palette = c(weak = "#f2f0f7", moderate = "#cbc9e2", strong = "#756bb1"),
      domain  = c("weak","moderate","strong"),
      na.color = "white"
    )
  ) |>
  cols_align(
    align = "center",
    columns = c(n, rho, `Observed sign`, `Observed band`,
                `Expected sign`, `Expected band`,
                `Band match`, `Sign match`, `Hypothesis met`)
  ) |>
  tab_options(
    heading.align = "left",
    table.font.size = "small",
    table.width = px(650),
    data_row.padding = px(2)
  )
Table 2. Construct Responsiveness of NDI
Instrument Pair N Spearman ρ Observed sign Observed band Expected sign Expected band Band match Sign match Hypothesis met
NDI vs CNFDS (function) 219 0.66 positive strong positive strong ✔ ✔ ✔
NDI vs CNFDS (pain) 236 0.67 positive strong positive moderate ✖ ✔ ✖
NDI vs SF-36 Physical Functioning 235 0.54 positive strong positive strong ✔ ✔ ✔
NDI vs SF-36 Bodily Pain 236 0.61 positive strong positive moderate ✖ ✔ ✖
NDI vs SF-36 Mental Health 232 0.38 positive moderate positive moderate ✔ ✔ ✔
NDI vs SF-36 PCS 219 0.62 positive strong positive strong ✔ ✔ ✔
NDI vs NRS (average pain) 237 0.27 positive weak positive moderate ✖ ✔ ✖

In summary:

The observed results showed strong correlations between the NDI and both function- and pain-related measures (CNFDS function, CNFDS pain, SF-36 PF, SF-36 BP, PCS). A moderate correlation was found with SF-36 Mental Health, while the correlation with the NRS was weak. In total, four hypotheses were confirmed and three were not. This overall pattern indicates that the NDI demonstrates reasonable responsiveness. The lack of full confirmation may be due to poorly specified hypotheses, which should ideally be grounded in the literature, or may reflect only medium responsiveness of the NDI in this dataset.

Next, you will turn to criterion responsiveness. Your dataset includes an external anchor, which makes it possible to test whether changes in the NDI correspond to the patient-reported anchor of change. You will examine this using both hypothesis testing (correlation with the anchor) and Receiver Operating Characteristic (ROC) analysis.

Questions

Question 2.1

Formulate a hypothesis that can be tested in your dataset. The hypothesis should:

  • Be plausible but not trivial (challenging)
  • Specify a direction (positive or negative)
  • Indicate an expected correlation strength (weak, moderate, strong, based on Cohen’s criteria)
  • Provide a reason for expecting this relationship
ImportantAnswer

We hypothesize a moderate positive correlation (r = 0.30–0.50) between change in the NDI and the external anchor of global perceived effect. The direction is expected to be positive, since greater improvement on the anchor (higher perceived improvement) should correspond to larger decreases in disability scores. The relationship is expected to be moderate rather than strong, because the NDI measures functional disability while the anchor reflects a broader global impression of change that also includes factors beyond disability.

2.2 How would you perform a Receiver Operating Characteristic (ROC) analysis to evaluate criterion responsiveness in your dataset?

Specifically:

  • Explain what a ROC curve tells us
  • Describe the steps you would take to conduct the ROC analysis (from preparing the anchor to calculating the AUC)
  • Draw a ROC curve (a simple sketch is fine) showing how you expect the curve to look and label the axes.
  • Explain what would be considered an acceptable result (i.e., how high the AUC should be for the instrument to be judged responsive)
ImportantAnswer

A ROC curve in responsiveness analysis shows how well a change score on an instrument (e.g., NDI) can discriminate between patients who report improvement (according to an external anchor) and those who do not. A higher AUC indicates that the instrument is more sensitive to true change and can more accurately distinguish improved from non-improved patients.

To perform the ROC analysis, I would first dichotomize the external anchor into improved vs. not improved. Next, I would use the change score from the NDI as the test variable and the dichotomized anchor as the reference. Then, I would calculate the ROC curve by plotting sensitivity (true positive rate) against 1-specificity (false positive rate) across all possible cut-off points of the NDI change score.

I expect the ROC curve to bow above the diagonal line of no discrimination. The x-axis should be labeled “1 − Specificity (false positive rate)” and the y-axis “Sensitivity (true positive rate).” The diagonal line represents random chance (AUC = 0.5). A responsive measure should show a curve clearly above this line, ideally with an AUC ≥ 0.70.

According to the COSMIN methodology, an AUC ≥ 0.70 is considered sufficient responsiveness.

In our data we find the following (Figure 1).

Code
# 1. Dichotomize anchor into "improved" vs "not improved"
resp_data <- resp_data |>
  mutate(
    anchor_dic = case_when(
      anchor_g3 %in% c(1, 2) ~ 1,  # improved
      anchor_g3 %in% c(3, 4, 5) ~ 0,  # not improved
      TRUE ~ NA_real_
    )
  )

# View(resp_data |> select(ndi10_change, anchor_g3, anchor_dic)) # Checking dichotomisation

# 2. Run ROC analysis
roc_obj <- roc(
  response = resp_data$anchor_dic,
  predictor = resp_data$ndi10_change,
  direction = ">",   # Lower NDI score = better function
  na.rm = TRUE
)

# 3. Extracting data for ROC curve
roc_df <- data.frame(
  specificity = rev(roc_obj$specificities),
  sensitivity = rev(roc_obj$sensitivities)
)

auc_val <- round(pROC::auc(roc_obj), 2) # The AUC value

# 4. Plot ROC curve using ggplot2

ggplot(roc_df, aes(x = 1 - specificity, y = sensitivity)) +
  geom_line(color = "blue", linewidth = 1) +
  geom_abline(intercept = 0, slope = 1, 
              linetype = "dashed", color = "grey50") +
  # AUC text
  annotate("text", x = 0.1, y = 0.8, 
           label = paste0("AUC = ", auc_val),
           hjust = 0, size = 4, color = "black") +
  labs(
    title = "Figure 1. Receiver Operating Characteristic curve of the NDI",
    x = "1 - Specificity (false positive rate)",
    y = "Sensitivity (true positive rate)"
  ) +
  scale_x_continuous(
  limits = c(-0.02, 1.02), 
  expand = c(0, 0), 
  breaks = seq(0, 1, 0.1)
) +
scale_y_continuous(
  limits = c(-0.02, 1.02), 
  expand = c(0, 0), 
  breaks = seq(0, 1, 0.1)
) +
  theme_minimal() +
  theme(
    panel.grid = element_blank(),                 # no grid
    panel.background = element_rect(fill="white", color=NA), # white background
    axis.line = element_line(color = "black"),    # black axes
    axis.ticks = element_line(color = "black")    # black ticks
  )

We find and AUC of 0.765 and consider this acceptable.

To download the answers provided in this exercise, right-click on the page and choose ‘save as’. This saves a standalone html page (sometimes a folder with relevant html information is also created).

Download the ‘resp_data.rds’. You find the dataset here:

(right-click the link and choose ‘Save as’)

To import it into R use the code below. R-code is provided throughout the exercise:

Code
# Importing the 'resp_data.rds'.

resp_data <- readRDS("resp_data.rds") |> 
  relocate(PHS_change, .before = MHS_change) |> 
  rename(
    pcs_change = "PHS_change",
    mcs_change = "MHS_change"
  )

The R libraries used are these:

Code
library(tidyverse)  # data wrangling (dplyr/tidyr), plotting (ggplot2), tibbles, helpers
library(glue)       # Working with strings
library(gt)         # nicely formatted tables in Quarto
library(here)       # For locating root folder
library(skimr)      # quick dataset overviews with skim()
library(summarytools) # Frequency tables for variables
library(pROC)       # ROC analyses