Exercise on reproducibility - answers

Back to the main page

Reproducibility

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

You have taken part in a validation study of the Oswestry Disability Index (ODI) in patients with chronic low back pain. Before applying the index in a clinical trial, you want to examine its reproducibility.

As part of the validation, a test–retest study was conducted with 150 patients recruited from both the primary care sector (medical doctors, physiotherapists, chiropractors) and the secondary care sector (an outpatient spine unit). The retest interval was approximately two weeks. Since the patients were on a waiting list during this period, their level of back pain–related disability was considered stable.

The ODI

The ODI includes 10 items, each addressing a daily activity such as pain intensity, personal care, lifting, walking, sitting, standing, sleeping, sex life, social life, and travelling. For each item, the respondent selects one of six statements, scored from 0 to 5, with higher scores indicating greater disability. The item scores are summed and then converted to a percentage score ranging from 0 to 100 by dividing the total score by the maximum possible score (adjusted for the number of items completed).

The Danish version of ODI can be found here

The dataset

The exercise is based on a dataset named osw_reprod_10items.rds. It includes a patient ID number, the 10 ODI items recorded at baseline and again at two-week follow-up, as well as the total ODI scores for each time point.

The variable names follow this structure

  • osw1 = item 1
  • _1 = baseline (time 1, t1)
  • _2 = follow-up (time 2, t2)

The dataset structure is shown in Table 1.

Code
reprod_data <- readRDS(here("files", "02_advanced_course", "day2", "exercises", "reproducibility", "Synthetic data", "osw_reprod_10items.rds"))
  
# Skal ændres når overføres til hjemmesiden

reprod_data |>
  slice_head(n = 6) |>                     # show first 6 rows
  gt() |>
  tab_header(
    title = "Table 1. First 6 lines of the dataset"
  ) |> 
  cols_align(
    align = "center",
    columns = everything()) |>             # center short numbers
  cols_width(everything() ~ px(28)) |>     # narrow columns
  tab_options(
    table.font.size      = px(10),         # smaller font; try 9–11 px
    data_row.padding     = px(1),          # tight row padding
    column_labels.padding= px(2),
    table.width          = pct(100),       # use full content width
    heading.align = "left"
  )
Table 1. First 6 lines of the dataset
patient Pain intensity (t1) Personal care (t1) Lifting (t1) Walking (t1) Sitting (t1) Standing (t1) Sleeping (t1) Sexlife (if applicable) (t1) Social life (t1) Travelling (t1) Pain intensity (t2) Personal care (t2) Lifting (t2) Walking (t2) Sitting (t2) Standing (t2) Sleeping (t2) Sexlife (if applicable) (t2) Social life (t2) Travelling (t2) Total ODI score (baseline) Total ODI score (follow-up)
1 0 2 NA 0 1 2 0 0 1 1 0 2 1 1 1 2 1 1 1 1 16 22
2 1 3 2 1 1 1 0 0 1 2 1 2 1 1 3 2 NA 1 2 2 24 33
3 2 3 3 1 3 2 2 3 2 2 3 4 3 3 2 4 3 3 2 2 46 58
4 1 2 2 1 2 3 NA 1 2 1 2 2 2 2 3 3 2 2 3 2 33 46
5 3 2 1 2 2 2 0 2 2 2 2 2 2 2 2 3 2 2 2 2 36 42
6 1 2 0 2 3 4 2 2 2 3 2 3 3 2 2 3 2 2 3 2 42 48

The variables are summarised below:

Code
# This is for showing a summary of the dataset

skim(reprod_data)
Data summary
Name reprod_data
Number of rows 150
Number of columns 23
_______________________
Column type frequency:
numeric 23
________________________
Group variables None

Variable type: numeric

skim_variable n_missing complete_rate mean sd p0 p25 p50 p75 p100 hist
patient 0 1.00 75.50 43.45 1 38.25 75.5 112.75 150 ▇▇▇▇▇
osw1_1 5 0.97 1.25 1.00 0 1.00 1.0 2.00 5 ▇▃▁▁▁
osw2_1 5 0.97 1.81 1.09 0 1.00 2.0 2.00 5 ▇▇▃▁▁
osw3_1 5 0.97 1.45 1.04 0 1.00 1.0 2.00 5 ▇▃▂▁▁
osw4_1 5 0.97 1.06 1.10 0 0.00 1.0 2.00 5 ▇▂▁▁▁
osw5_1 5 0.97 1.60 1.08 0 1.00 2.0 2.00 5 ▇▅▂▁▁
osw6_1 5 0.97 2.01 1.03 0 1.00 2.0 3.00 5 ▆▇▃▂▁
osw7_1 5 0.97 1.12 1.08 0 0.00 1.0 2.00 5 ▇▃▁▁▁
osw8_1 5 0.97 1.23 0.93 0 1.00 1.0 2.00 4 ▅▇▅▂▁
osw9_1 5 0.97 1.50 1.09 0 1.00 1.0 2.00 4 ▅▇▆▂▁
osw10_1 5 0.97 1.43 0.95 0 1.00 1.0 2.00 4 ▂▇▅▂▁
osw1_2 9 0.94 1.74 0.97 0 1.00 2.0 2.00 5 ▇▆▃▁▁
osw2_2 9 0.94 2.26 0.95 0 2.00 2.0 3.00 5 ▅▇▅▂▁
osw3_2 9 0.94 1.83 0.97 0 1.00 2.0 2.00 4 ▁▇▇▃▁
osw4_2 9 0.94 1.62 1.01 0 1.00 2.0 2.00 5 ▇▅▂▁▁
osw5_2 9 0.94 2.14 0.96 0 1.00 2.0 3.00 5 ▅▇▅▁▁
osw6_2 9 0.94 2.65 0.92 1 2.00 3.0 3.00 5 ▂▇▆▃▁
osw7_2 9 0.94 1.64 0.95 0 1.00 2.0 2.00 4 ▂▇▇▂▁
osw8_2 9 0.94 1.72 0.92 0 1.00 2.0 2.00 5 ▇▆▂▁▁
osw9_2 9 0.94 2.00 0.91 0 1.00 2.0 3.00 5 ▅▇▅▁▁
osw10_2 9 0.94 1.96 0.96 0 1.00 2.0 3.00 5 ▆▇▃▁▁
osw_total_1 0 1.00 28.97 15.36 2 18.00 28.0 38.00 87 ▅▇▃▁▁
osw_total_2 0 1.00 39.25 16.38 8 26.00 39.0 49.75 86 ▃▇▇▃▁

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

Please write your answers to the questions either in a Word document or on paper. The exercise including answers can be downloaded after the course when activated.

The first thing you do is to calculate the Pearson’s correlation coefficient between the ODI sumscores of t1 and t2. The results are found in Table 2 and visualised in Figure 1.

Code
# Selecting t1 and t2 total scores
corr <- reprod_data |> 
  select(osw_total_1, osw_total_2)

# Pearson's correlation
pcorr <- cor.test(corr$osw_total_1, corr$osw_total_2, method = "pearson", use = "complete.obs") 

# Tidy the correlation test result
pcorr_tidy <- tidy(pcorr) |> 
  select(estimate, statistic, p.value, conf.low, conf.high)

# Create a GT table
(pcorr_table <- pcorr_tidy |>
  gt() |>
  tab_header(
    title = "Table 2. Correlation between ODI scores at time 1 and 2"
  ) |>
  fmt_number(
    columns = c(estimate, statistic, p.value, conf.low, conf.high),
    decimals = 2
  ) |>
    cols_merge(
      columns = c(conf.low, conf.high),
      pattern = "({1}; {2})"
      ) |> 
  cols_label(
    estimate = "Pearson CC",
    statistic = "t-statistic",
    p.value = "p-value",
    conf.low = "CI"
  )) |> 
  cols_align(align = "center", columns = everything())
Table 2. Correlation between ODI scores at time 1 and 2
Pearson CC t-statistic p-value CI
0.94 32.64 0.00 (0.91; 0.95)
Code
# Generating a scatter plot

plot_dat <- reprod_data |>
  filter(!is.na(osw_total_1), !is.na(osw_total_2))

# prepare a concise subtitle using your test results
r_lab  <- sprintf("r = %.2f", pcorr_tidy$estimate)
ci_lab <- sprintf("95%% CI %.2f–%.2f", pcorr_tidy$conf.low, pcorr_tidy$conf.high)
n_cc   <- nrow(plot_dat)

cor_plot <- ggplot(plot_dat, aes(x = osw_total_1, y = osw_total_2)) +
  geom_point(alpha = 0.4, color = "blue") +                    # observed pairs
  geom_abline(slope = 1, intercept = 0, linetype = "dashed") +  # identity line
  scale_x_continuous(limits = c(0, 100)) +                    # x-axis 0–100
  scale_y_continuous(limits = c(0, 100)) +                    # y-axis 0–100
  labs(
    title = "Figure 1. Scatter plot of ODI scores at t1 and t2",
    subtitle = paste(r_lab, " | ", ci_lab, sprintf("| n = %d", n_cc)),
    x = "t1 ODI scores",
    y = "t2 ODI scores"
  ) +
  theme_classic() +                                          # clean base
  theme(
    axis.line = element_line(color = "black"),               # black axes
    axis.ticks = element_line(color = "black"),              # black ticks
    panel.grid = element_blank(),                            # remove gridlines
    axis.text = element_text(color = "black"),               # black labels
    axis.title = element_text(color = "black")
  )
cor_plot

Questions

1.1 What is the Pearson’s correlation coefficient and the associated p-value?

ImportantAnswer

The Person’s correlation coefficient is 0.94 with a p-value of < .001.

1.2 Discuss what the correlation coefficient tell us about the reliability between the two measurements?

ImportantAnswer

Pearson’s correlation (\(r\)) tells you whether people keep the same rank order from time 1 to time 2, i.e. do those who score high the first time also score high the second time? A high \(r\) therefore indicates good consistency, but it is not a measure of exact agreement.

If all scores at t2 were shifted up by a constant (or stretched by a constant factor), \(r\) would hardly change, so systematic bias and scale differences are invisible to it. The coefficient is also sensitive to range restriction (it falls in very homogeneous samples) and to outliers, and it does not show whether differences widen at higher scores (heteroscedasticity).

In practice, \(r\) should not be reported as a measures of reliability as it only describes a linear association. You should base conclusions about reliability on an ICC for absolute agreement (reliability).

1.3 Explain what the p-value means?

ImportantAnswer

The p-value tells you how likely your observed correlation (or a more extreme one) would be if the true correlation were 0 in the population. A small p-value means the data are unlikely under “no association,” so there is evidence of some linear relationship. It doesn’t tell how strong the relationship is or how close \(r\) is to 1.

You now want to have a look at the intra-class correlation coefficients (ICC) and standard error of the measurements (SEM) for the measurements. The ICC’s are presented as the output you will get when using the psych package.

Code
# Run ICC using matrix
icc_data <- as.matrix(corr)                   # psych::ICC wants matrix or data.frame
icc_out  <- psych::ICC(icc_data, lmer = TRUE) # includes $results and variance comps

icc_out
Call: psych::ICC(x = icc_data, lmer = TRUE)

Intraclass correlation coefficients 
                         type  ICC    F df1 df2       p lower bound upper bound
Single_raters_absolute   ICC1 0.75  7.1 149 150 3.5e-29       0.673        0.81
Single_random_raters     ICC2 0.77 29.8 149 149 2.7e-69      -0.055        0.93
Single_fixed_raters      ICC3 0.94 29.8 149 149 2.7e-69       0.911        0.95
Average_raters_absolute ICC1k 0.86  7.1 149 150 3.5e-29       0.805        0.90
Average_random_raters   ICC2k 0.87 29.8 149 149 2.7e-69      -0.116        0.96
Average_fixed_raters    ICC3k 0.97 29.8 149 149 2.7e-69       0.954        0.98

 Number of subjects = 150     Number of Judges =  2
See the help file for a discussion of the other 4 McGraw and Wong estimates,

Questions

2.1 Explain which coefficients should be used in a test-retest situation in the output from the psych package. You are welcome to use the teaching material (vodcast or PowerPoint pdf), the psych ICC help file in R if you have it installed, or chatGPT/Perplexity/Copilot or the like.

Important

For test–retest reliability, a two-way mixed-effects model is generally appropriate because the same participants are measured on two specific occasions (t1 and t2).

Two ICC definitions can be considered:

ICC(A,1) – Absolute agreement: This coefficient includes systematic differences between measurement occasions in the assessment of disagreement. It evaluates whether measurements obtained at t1 and t2 are numerically similar. This is the preferred ICC for test–retest reliability when one measurement is intended for use in practice.

ICC(C,1) – Consistency: This coefficient excludes systematic differences between the mean scores at t1 and t2. It evaluates whether participants retain approximately the same relative standing across measurement occasions.

Remember that the relevant ICC’s important to test-retest are as follows:

  • ICC2 = ICC(A,1), mixed effects = Absolute agreement where you want interchangeability of occasions (including systematic error)
  • ICC3 = ICC(C,1), mixed effects = Relative consistency between occasions and your two occasions are fixed

Although ICC2 is traditionally associated with a two-way random-effects model, its formula is identical to the McGraw and Wong two-way mixed-effects absolute-agreement ICC(A,1).

The difference between the coefficients indicates that systematic differences between occasions may substantially affect absolute agreement.

Conclusion: For assessing test–retest reliability of a single measurement, ICC(A,1) = 0.77 is the preferred coefficient. ICC(C,1) = 0.94 may be presented as additional information about relative consistency.

The ICC output from the psych package is matched with McGraw and Wong (1996) in Table 3.

Code
# 1. Extract the six ICC results

icc_df <- as_tibble(icc_out$results) |>
  mutate(
    Psych_ICC = as.character(type),
    ICC_MW = recode(Psych_ICC,
      "ICC1"  = "ICC(1)",
      "ICC2"  = "ICC(A,1)",
      "ICC3"  = "ICC(C,1)",
      "ICC1k" = "ICC(k)",
      "ICC2k" = "ICC(A,k)",
      "ICC3k" = "ICC(C,k)"
    ),
    Description = recode(Psych_ICC,
      "ICC1"  = "One-way random, single, agreement",
      "ICC2"  = "Two-way random, single, absolute agreement",
      "ICC3"  = "Two-way mixed, single, consistency",
      "ICC1k" = "One-way random, average, agreement",
      "ICC2k" = "Two-way random, average, absolute agreement",
      "ICC3k" = "Two-way mixed, average, consistency"
    )
  ) |>
  transmute(
    ICC_MW,
    Psych_ICC,
    Description,
    ICC_Value = ICC,
    Lower_CI = `lower bound`,
    Upper_CI = `upper bound`
  )

# 2. Create Table 3 with styling similar to screenshot

table3 <- gt(icc_df) |>
  tab_header(
    title = "Table 3. Intraclass Correlation Coefficients (95% CIs)"
  ) |>
  fmt_number(
    columns = c(ICC_Value, Lower_CI, Upper_CI),
    decimals = 2
  ) |>
  cols_merge_range(
    col_begin = Lower_CI,
    col_end = Upper_CI
  ) |>
  cols_label(
    ICC_MW = "ICC (McGraw & Wong)",
    Psych_ICC = "Psych ICC",
    Description = "Model",
    ICC_Value = "ICC",
    Lower_CI = "95% CI"
  ) |>
  cols_align(
    align = "center",
    columns = c(ICC_MW, Psych_ICC, ICC_Value, Lower_CI)
  ) |>
  cols_align(
    align = "left",
    columns = Description
  ) |>

  # Alternating light-grey rows
  tab_style(
    style = cell_fill(color = "#F2F2F2"),
    locations = cells_body(rows = c(1, 3, 5))
  ) |>

  # General appearance
  tab_options(
    table.font.size = px(12),
    table.width = pct(100),
    data_row.padding = px(5),

    heading.title.font.size = px(14),
    heading.title.font.weight = "normal",
    heading.align = "center",

    column_labels.font.weight = "normal",
    column_labels.background.color = "white",

    table_body.hlines.style = "solid",
    table_body.hlines.color = "#CCCCCC",
    table_body.hlines.width = px(1),

    table.border.top.style = "solid",
    table.border.top.color = "#AAAAAA",
    table.border.top.width = px(1),

    table.border.bottom.style = "solid",
    table.border.bottom.color = "#AAAAAA",
    table.border.bottom.width = px(1),

    source_notes.font.size = px(11)
  ) |>

  # Note below the table
  tab_source_note(
    md(
      paste(
        "*Note.* ICC2 and ICC2k correspond to two-way random",
        "absolute agreement in the psych output.",
        "The same point-estimate formulas apply to",
        "two-way mixed-effects absolute agreement.",
        "For test-retest reliability with fixed occasions,",
        "the mixed-effects interpretation is appropriate.",
        "Mixed-effects average-measure coefficients require",
        "Case 3A (without interaction)."
      )
    )
  )

# Display table
table3
Table 3. Intraclass Correlation Coefficients (95% CIs)
ICC (McGraw & Wong) Psych ICC Model ICC 95% CI
ICC(1) ICC1 One-way random, single, agreement 0.75 0.67–0.81
ICC(A,1) ICC2 Two-way random, single, absolute agreement 0.77 −0.05–0.93
ICC(C,1) ICC3 Two-way mixed, single, consistency 0.94 0.91–0.95
ICC(k) ICC1k One-way random, average, agreement 0.86 0.80–0.90
ICC(A,k) ICC2k Two-way random, average, absolute agreement 0.87 −0.12–0.96
ICC(C,k) ICC3k Two-way mixed, average, consistency 0.97 0.95–0.98
Note. ICC2 and ICC2k correspond to two-way random absolute agreement in the psych output. The same point-estimate formulas apply to two-way mixed-effects absolute agreement. For test-retest reliability with fixed occasions, the mixed-effects interpretation is appropriate. Mixed-effects average-measure coefficients require Case 3A (without interaction).

2.2 What do you think about the reliability (remember ICC2 = ICC(A,1) and ICC3 = ICC(C,1))?

ImportantAnswer

ICC(A,1) — Absolute agreement

The output from psych shows an ICC(A,1) of 0.77, however, the CI is very wide (-0.05; 0.93).

That means absolute agreement between t1 and t2 is uncertain (the lower bound even allows for essentially no reliability). The difference between agreement and consistency suggests a systematic difference between measurement occasions.

ICC(C,1) — Consistency

The output shows an ICC(C,1) of 0.94 (95% CI: [0.91, 0.95]), which is considered excellent.

It tells us participants retain approximately the same relative standing from t1 to t2, but systematic differences between occasion means are excluded from the assessment of disagreement.

Next, you turn to looking at the variance components of a repeated measures ANOVA. You want to calculate ICC (reliability) and SEM (measurement error) using the values in Table 4.

Code
# We use the data.frame 'icc_results' and extract the variance components from the ICC calculations in psych

# Generating tibble with variance components
icc_variance <- icc_out[["lme"]] |> 
  rownames_to_column(var = "variance_component") |> 
  select(-Percent) |> 
  as_tibble() |> 
  mutate(across(where(is.numeric), ~round(., 3))) |> 
  mutate(variance_component = recode(variance_component, 
                                     "ID" = "Patients", 
                                     "Items" = "Time points"))

# Generating Table 2 with variance components

table4 <- gt(icc_variance) |> 
  cols_align(
    align = "center",
    columns = variance
  ) |> 
  tab_header(
    title = md("**Table 4. Variance components**")
  ) |> 
  opt_align_table_header(
    align = "left"
  ) |> 
   cols_label(
    variance_component = "Variance components",
    variance = "Variance"
  ) |> 
  tab_options(
    table.font.size = px(14),
    table.align = "center",
    table.border.top.color = "transparent", # Remove top border around table
     data_row.padding = px(3) # Reduce the height of rows
  )
table4
Table 4. Variance components
Variance components Variance
Patients 235.679
Time points 52.725
Residual 16.363
Total 304.767

Question

2.3 Using the variance estimates, please calculate ICC(C,1), ICC(A,1), SEMconsistency, and SEMagreement.

ImportantAnswer

\[ICC_{consistency} = ICC(C,1) = \frac{\sigma^2_p}{\sigma^2_p + \sigma^2_{po,e}} = \frac{235.679}{(235.679 + 16.363)} = 0.935\]

\[ \begin{aligned} ICC_{\text{agreement}} &= ICC(A,1) = \frac{\sigma^2_p}{\sigma^2_p + \sigma^2_o + \sigma^2_{po,e}} = \\ \\ & \tfrac{235.679}{235.679 + 52.725 + 16.363} = 0.773 \end{aligned} \] \[SEM_{consistency} = \sqrt{\sigma^2_{po,e}} = \sqrt{16.363} = 4.05\]

\[SEM_{agreement} = \sqrt{\sigma^2_o + \sigma^2_{po,e}} = \sqrt{52.725 + 4.414} = 8.31\]

2.4 What do you think about the measurement error?

Code
#-----Preparing variables for adding to text----------------------------------

# 1) Pull variance components directly by row name (robust & simple)
sigma2_p    <- icc_out$lme["ID",      "variance"]   # patients
sigma2_o    <- icc_out$lme["Items",   "variance"]   # time points / occasions
sigma2_poe  <- icc_out$lme["Residual","variance"]   # person×occasion + residual

# 2) Coefficients (single-measure)
icc_consistency <- sigma2_p / (sigma2_p + sigma2_poe)
icc_agreement   <- sigma2_p / (sigma2_p + sigma2_o + sigma2_poe)

sem_consistency <- sqrt(sigma2_poe)
sem_agreement   <- sqrt(sigma2_o + sigma2_poe)

# 3) Store values for easy inline use in Quarto
icc_sem_vals <- list(
  sigma2_p = sigma2_p,
  sigma2_o = sigma2_o,
  sigma2_poe = sigma2_poe,
  icc_consistency = icc_consistency,
  icc_agreement   = icc_agreement,
  sem_consistency = sem_consistency,
  sem_agreement   = sem_agreement
)

# 4) Also prepare pretty, thousands-separated strings (optional, handy for formulas)
fmt <- function(x, digits = 3) formatC(x, format = "f", digits = digits, big.mark = ",")
icc_sem_str <- list(
  s2p   = fmt(sigma2_p),
  s2o   = fmt(sigma2_o),
  s2poe = fmt(sigma2_poe),
  icc_c = round(icc_consistency, 3),
  icc_a = round(icc_agreement,   3),
  sem_c = round(sem_consistency, 2),
  sem_a = round(sem_agreement,   2),
  denom_c = fmt(sigma2_p + sigma2_poe),
  denom_a = fmt(sigma2_p + sigma2_o + sigma2_poe)
)

# --- Min/Max (and range) for t1 and t2 -----------------------------------
spread_tbl <- reprod_data |>
  summarise(
    t1_min = min(osw_total_1, na.rm = TRUE),   # min at baseline
    t1_max = max(osw_total_1, na.rm = TRUE),   # max at baseline
    t2_min = min(osw_total_2, na.rm = TRUE),   # min at follow-up
    t2_max = max(osw_total_2, na.rm = TRUE)    # max at follow-up
  ) |>
  pivot_longer(everything(),
               names_to   = c("time", "stat"),
               names_pattern = "(t[12])_(min|max)",
               values_to  = "value") |>
  pivot_wider(names_from = stat, values_from = value) |>
  mutate(
    range = max - min,                          # simple spread measure
    range_str = sprintf("%d–%d", min, max)      # handy for inline text
  ) |>
  arrange(time)
ImportantAnswer

Measurement error (single score):

The relevant index is SEMagreement = 8.31 points on the 0–100 ODI scale. This reflects the typical absolute error including occasion effects (the right choice for test–retest). For comparison, SEMconsistency = 4.05 points excludes the occasion component and therefore underestimates absolute error.

Baseline scores ranged 2–87, and follow-up 8–86. So there is plenty of between-person variability (which helps ICC), but the ~8.31-point error is not trivial for interpreting individual change.

SEMconsistency = 4.05, is the measurement error without the systematic error. This is about half the SEMagreement pointing to a large systematic error. Therefore:

  • The SEMagreement is moderate compared to the variance of the data (score range t1: 2–87 and t2: 8–86)
  • The reliability is good as it is > 0.7

Next, examine systematic and random error using the Bland–Altman limits of agreement (LoA). As a first step, review the descriptive statistics for ODI totals at baseline (t1) and two-week follow-up (t2) in Table 5.

Code
odi_summary_dta <- reprod_data |>
  mutate(osw_ch = osw_total_2 - osw_total_1) |> 
  select(osw_total_1, osw_total_2, osw_ch) |>
  pivot_longer(
    everything(),
    names_to  = "time",                # osw_total_1 / osw_total_2 -> "t1"/"t2"
    values_to = "total"
  ) |>
  mutate(time = recode(time, 
                       osw_total_1 = "t1", 
                       osw_total_2 = "t2",
                       osw_ch = "Difference"),
         time = factor(time, levels = c("t1", "t2", "Difference"))) |>
  group_by(time) |>
  summarise(
    n    = sum(!is.na(total)),         # number of non-missing totals
    mean = mean(total, na.rm = TRUE),  # mean at that time
    sd   = sd(total,   na.rm = TRUE),  # SD at that time
    .groups = "drop"
  )

# gt-table

odi_summary_tbl <- gt(odi_summary_dta) |>
  tab_header(
    title = md("**Table 5. Descriptive statistics for the ODI**")
  ) |>
  cols_label(
    time = "Time",
    n    = "n",
    mean = "Mean",
    sd   = "SD"
  ) |>
  fmt_number(columns = c(mean, sd), decimals = 2) |>
  cols_align(align = "center", columns = everything()) |>
  tab_options(
    table.font.size = px(14),
    data_row.padding = px(3),
    table.align = "center"
  ) |>
  tab_source_note(
    source_note = "ODI scores are on a 0–100 scale, 'Difference' represents follow-up (t2) minus baseline (t1)."
  )

odi_summary_tbl
Table 5. Descriptive statistics for the ODI
Time n Mean SD
t1 150 28.97 15.36
t2 150 39.25 16.38
Difference 150 10.28 5.72
ODI scores are on a 0–100 scale, 'Difference' represents follow-up (t2) minus baseline (t1).
Code
# Values for LOA calculations

# Q 3.2
loa_mean <- round(odi_summary_dta$mean[odi_summary_dta$time == "Difference"], 2)
loa_sd <- round(odi_summary_dta$sd[odi_summary_dta$time == "Difference"], 2)
loa <- round(1.96 * odi_summary_dta$sd[odi_summary_dta$time == "Difference"], 2)
loa_lower <- (loa_mean - loa)
loa_upper <- (loa_mean + loa)

# Q 3.4
t1_mean <- round(odi_summary_dta$mean[odi_summary_dta$time == "t1"], 2)
t2_mean_20 <- (t1_mean + 20)
loa_lower_20 <- round(20 - (1.96 * odi_summary_dta$sd[odi_summary_dta$time == "Difference"]), 2)
loa_upper_20 <- round(20 + (1.96 * odi_summary_dta$sd[odi_summary_dta$time == "Difference"]), 2)

Questions

3.1 What is the systematic difference? Which time-point has the highest average?

ImportantAnswer

The systematic difference (t2 – t1) is 10.28 points.

Time 2 (t2 or retest) has the highest mean ODI score of 39.25 points.

3.2 What are the LOA’s (limits of agreement)?

ImportantAnswer

\[ LOA = 10.28 \pm (1.96 \cdot 5.72) = 10.28 \pm 11.21 = [-0.93; 21.49] \]

3.3 What will happen with ICCconsistency and ICCagreement if time 2 always measures 20 points higher compared to time 1?

ImportantAnswer

If time 2 consequently measures 20 points higher compared to time 1, then:

  • ICCconsistency will stay the same
  • ICCagreement will be much lower as it includes systematic error which is now twice as much as in Table 5.

3.4 What will happen to the “limits of agreement”?

ImportantAnswer
  • If time 2 consequently measures 20 points higher compared to time 1, the mean ODI score at time 2 will be 48.97 (i.e. 28.97 + 20).
  • The width of the LOA stays the same, but we get higher LOA limits:

\[ LOA = 20 \pm (1.96 \cdot 5.72) = [8.79; 31.21] \]

You now generate a Bland & Altman Limits of agreement plot of the data. The plot is presented in Figure 2.

Code
# --- Prepare BA data (pairwise complete cases)
ba_dta <- reprod_data |>
  transmute(
    mean = (osw_total_1 + osw_total_2) / 2,   # mean of the two totals
    diff =  osw_total_2 - osw_total_1         # t2 - t1 (systematic difference)
  ) |>
  drop_na()

# --- BA plot stats
n_ba     <- nrow(ba_dta)
mdiff    <- mean(ba_dta$diff)                     # mean difference
sd_diff  <- sd(ba_dta$diff)                       # SD of differences
loa_low  <- mdiff - 1.96 * sd_diff            # lower LoA
loa_high <- mdiff + 1.96 * sd_diff            # upper LoA

# --- 95% CIs for LOA

se_mdiff <- sd_diff / sqrt(n_ba)
se_loa <- sd_diff * sqrt(1/n_ba + (1.96^2)/(2*(n_ba - 1)))
mdiff_ci <- c(mdiff - 1.96 * se_mdiff, mdiff + 1.96 * se_mdiff)
loa_low_ci  <- c(loa_low  - 1.96 * se_loa, loa_low  + 1.96 * se_loa)
loa_high_ci <- c(loa_high - 1.96 * se_loa, loa_high + 1.96 * se_loa)

# --- Bland–Altman plot

ba_plot <- ggplot(ba_dta, aes(x = mean, y = diff)) +
  geom_point(alpha = 0.6, color = "steelblue") +         # data points
  geom_hline(yintercept = mdiff, linewidth = 0.6, color = "red") +   # mean diff
  geom_hline(yintercept = loa_low,linetype = "dashed") +
  geom_hline(yintercept = loa_high, linetype = "dashed") +
  geom_hline(yintercept = 0, linewidth = 0.6) +
  # labels on the right margin
  annotate("text", x = Inf, y = mdiff,
           label = paste0("Mean diff. = ", sprintf("%.2f", mdiff)),
           hjust = 1.02, vjust = -0.4, size = 3.5) +
  annotate("text", x = Inf, y = loa_high,
           label = paste0("Upper LoA = ", sprintf("%.2f", loa_high)),
           hjust = 1.02, vjust = -0.4, size = 3.5) +
  annotate("text", x = Inf, y = loa_low,
           label = paste0("Lower LoA = ", sprintf("%.2f", loa_low)),
           hjust = 1.02, vjust = 1.4, size = 3.5) +
  scale_x_continuous(
    limits = c(0, 100),
    breaks = seq(0, 100, by = 10)
    ) + 
  labs(
    title = "Figure 2. Bland–Altman plot of the ODI",
    x = "Mean ODI score of t1 and t2 (0-100)",
    y = "Difference in ODI score (t2 − t1)"
  ) +
  theme_classic() +                                      # clean look: black axes, no grid
  theme(
    axis.line  = element_line(color = "black"),
    axis.ticks = element_line(color = "black"),
    axis.text  = element_text(color = "black"),
    axis.title = element_text(color = "black")
  )
ba_plot

3.5 What does Figure 2 show, and how should it be interpreted?

ImportantAnswer

Large mean difference
The plot shows a large positive mean difference of 10.28 points, which suggests the patients may not have been stable (have got worse over the 2 weeks follow-up) or that something in the test–retest design introduced a systematic shift. Typical design causes include:

  • Different instructions or guidance at t1 vs. t2
  • A different context at retest (time of day the questionnaire is filled out, online vs. paper, at clinic vs. at home etc.)
  • Medication changes during the 2 weeks (possible but unlikely that all 150 patients should have changed their medication and got worse)
  • Response-shift effects (a change in how people judge or define what they’re rating (recalibration, reconceptualisation and reprioritisation), so scores differ even when their true health hasn’t changed)

Width of the LoA
The 95% prediction interval runs from -0.93 to 21.49. Thus, for a stable person, the retest score should be within 11.2 points higher or 11.2 lower than baseline purely due to measurement error (of consistency). Relative to the 0–100 ODI scale, the LoA interval is fairly wide, indicating a possible non-trivial error for individual patient decisions (again this depends on the effect expected of the intervention in a trial where the questionnaire is used).

Heteroscedasticity
The cloud of points shows greater variability at lower ODI mean scores (\(\approx\) 20-50) that narrows at higher ODI mean scores, indicating non-constant variance (or heteroscedasticity). This can bias the LoA estimation. Check this by regressing the differences on the means. If the slope \(\neq\) 0, consider a variance-stabilising approach (e.g., percentage or log differences where appropriate) or a regression-based LoA (e.g., the Taffé’s method).

Outliers
Finally, a few outliers are visible. Outliers can inflate the SD of differences, widen the LoA, and slightly pull the mean difference. Therefore, inspect them to rule out data entry errors or procedural issues.

In a study by De Winter et al. (2004), two physiotherapists measured shoulder abduction (Figure 1) in 155 patients with unilateral shoulder pain using an electronic inclinometer (Figure 2). The outcome is the abduction angle in degrees.

Figure 3. Shoulder abduction

Figure 4. Inclinometer measuring the abduction angle

Table 6 reproduces their inter-rater reliability results for the painful and contralateral healthy shoulder.

Code
dewinter_agree <- data.frame(
  Condition = c("Painful shoulder", "Healthy shoulder"),
  PhysA_Mean_SD = c("69.5 (17.6)", "79.8 (7.6)"),
  PhysB_Mean_SD = c("68.8 (16.3)", "78.9 (8.4)"),
  Mean_Diff_A_B_SD = c("0.8 (10.0)", "0.9 (9.6)"),
  Agreement_less_5 = c("43%", "43%"),
  Agreement_less_10 = c("72%", "72%"),
  ICC = c(0.83, 0.28)
)

# Generate the table using gt
(table4 <- dewinter_agree |>
  gt() |>
  tab_header(
    title = md("**Table 6. Inter-rater reliability results**")
  ) |>
  cols_label(
    PhysA_Mean_SD = "Phys A (Mean (SD))",
    PhysB_Mean_SD = "Phys B (Mean (SD))",
    Mean_Diff_A_B_SD = "Mean diff. A-B (SD)",
    Agreement_less_5 = "< 5° Agreement",
    Agreement_less_10 = "< 10° Agreement",
    ICC = "ICC"
  ) |>
  fmt_number(
    columns = c(ICC),
    decimals = 2
  ) |>
    cols_align(
    align   = "center",
    columns = -1          # all columns except the first
  ) |> 
  tab_options(
    table.font.size = "small",
    table.width = pct(100)
  ))
Table 6. Inter-rater reliability results
Condition Phys A (Mean (SD)) Phys B (Mean (SD)) Mean diff. A-B (SD) < 5° Agreement < 10° Agreement ICC
Painful shoulder 69.5 (17.6) 68.8 (16.3) 0.8 (10.0) 43% 72% 0.83
Healthy shoulder 79.8 (7.6) 78.9 (8.4) 0.9 (9.6) 43% 72% 0.28

Questions

4.1 Despite identical “within-tolerance” agreement (43% within \(\pm\) 5° and 72% within \(\pm\) 10°) for both shoulders, the ICC differs markedly (0.83 vs 0.28). Why? What does this tell you about ICC?

ImportantAnswer

The ICC is a ratio of between-person variance to total variance. Look at the variance of the results of Phys A and Phys B, i.e. the SD:

  • Abduction of the healthy shoulder is almost the same, therefore SD is small: ICC is low due to a homogenous sample, therefore low reliability
  • Abduction of the painful shoulder varies more, therefore SD is large: ICC is high due to a heterogenous sample, therefore high reliability

In summary: ICC depends on the spread of the sample (“range restriction”). Two datasets can show the same absolute agreement within \(\pm\) 5°/\(\pm\) 10° yet very different ICCs because one has low between-person variability.

4.2 Discuss which parameter is preferrable for judging inter-rater reliability here?

ImportantAnswer

Whether one prefers degrees or ICC from 0-1 is a personal preference. Personally, I prefer degrees as it is more meaningful clinically and because ICC’s are more difficult to interpret.

Now we turn to the individual items of the ODI. The questionnaire has 10 items and you calculate the different kappa values (\(\kappa\)) of all 10 items. The results are shown in Table 5.

Code
# --- FUNCTION
# Computes unweighted kappa, quadratic-weighted kappa (Fleiss–Cohen),
# Brennan–Prediger kappa, and observed agreement for one item.
# 'item' must match the column name stem (e.g., "osw1" -> uses osw1_1 and osw1_2)

# Compute unweighted kappa, weighted (Fleiss–Cohen) kappa, Brennan–Prediger kappa
# + their 95% CIs (BP via Wilson CI on Po), and observed agreement.
# item must be the stem, e.g. "osw1" (expects columns osw1_1 and osw1_2).

calc_item_kappas <- function(dat, item, item_levels = 0:5, conf.level = 0.95) {
  # build expected column names
  c1 <- paste0(item, "_1")
  c2 <- paste0(item, "_2")
  if (!all(c(c1, c2) %in% names(dat))) {
    stop("Columns ", c1, " and/or ", c2, " not found in 'dat'.")
  }

  # keep complete pairs; weight definitions need common ordered levels
  pairs <- dat |>
    select(all_of(c(c1, c2))) |>
    drop_na()

  # if no data to compute on, return NA row (fail gracefully)
  if (nrow(pairs) == 0L) {
    return(tibble(
      item                        = item,
      kappa_unweighted            = NA_real_,
      kappa_unweighted_l95        = NA_real_,
      kappa_unweighted_u95        = NA_real_,
      kappa_weighted              = NA_real_,
      kappa_weighted_l95          = NA_real_,
      kappa_weighted_u95          = NA_real_,
      brennan_prediger            = NA_real_,
      brennan_prediger_l95        = NA_real_,
      brennan_prediger_u95        = NA_real_,
      observed_agreement          = NA_real_
    ))
  }

  # coerce to same ordered factor levels (ensures a square table incl. empty cats)
  t1 <- factor(pairs[[c1]], levels = item_levels, ordered = TRUE)
  t2 <- factor(pairs[[c2]], levels = item_levels, ordered = TRUE)

  # confusion matrix
  tab <- table(t1, t2)

  # kappa (DescTools returns a named numeric vector)
  k_unw <- DescTools::CohenKappa(tab, weights = "Unweighted",   conf.level = conf.level)
  k_wsq <- DescTools::CohenKappa(tab, weights = "Fleiss-Cohen", conf.level = conf.level)

  # observed agreement Po
  A  <- sum(diag(tab))      # exact agreements
  n  <- sum(tab)            # number of paired ratings
  po <- A / n

  # Brennan–Prediger (Prediger) kappa and its CI via linear transform of Po CI
  k_cat <- length(item_levels)             # intended #categories (stable even if some unused)
  a <- k_cat / (k_cat - 1)                 # slope of linear transform
  b <- -1 / (k_cat - 1)                    # intercept
  bp <- a * po + b                         # point estimate

  # Wilson CI for Po, then transform endpoints to BP CI
  po_ci <- DescTools::BinomCI(A, n, conf.level = conf.level, method = "wilson")
  bp_l  <- a * po_ci[, "lwr.ci"] + b
  bp_u  <- a * po_ci[, "upr.ci"] + b
  
  # clip to [-1,1] just in case of numerical edge cases
  bp_l  <- pmax(-1, bp_l)
  bp_u  <- pmin( 1, bp_u)

  tibble(
    item                        = item,
    kappa_unweighted            = unname(k_unw["kappa"]),
    kappa_unweighted_l95        = unname(k_unw["lwr.ci"]),
    kappa_unweighted_u95        = unname(k_unw["upr.ci"]),
    kappa_weighted              = unname(k_wsq["kappa"]),
    kappa_weighted_l95          = unname(k_wsq["lwr.ci"]),
    kappa_weighted_u95          = unname(k_wsq["upr.ci"]),
    brennan_prediger            = as.numeric(bp),
    brennan_prediger_l95        = as.numeric(bp_l),
    brennan_prediger_u95        = as.numeric(bp_u),
    observed_agreement          = po
  )
}


# --- USAGE

items <- paste0("osw", 1:10)                       # osw1 ... osw10
item_levels <- 0:5                                  # osw levels

kappa_tbl_all <- map_dfr(
  items,
  ~ calc_item_kappas(reprod_data, .x, item_levels = item_levels, conf.level = 0.95)
) |>
  mutate(across(where(is.numeric), ~ round(.x, 2))) |>
  arrange(parse_number(item))

# --- Generating gt table

kappa_gt <- kappa_tbl_all |>
  gt() |> 
  cols_merge(
    columns = c(kappa_unweighted_l95, kappa_unweighted_u95),
    pattern = "({1}; {2})"
  ) |>
  cols_merge(
    columns = c(kappa_weighted_l95, kappa_weighted_u95),
    pattern = "({1}; {2})"
  ) |>
  cols_merge(
    columns = c(brennan_prediger_l95, brennan_prediger_u95),
    pattern = "({1}; {2})"
  ) |> 
  cols_label(
    item                   = "Item",
    kappa_unweighted       = "Kappa",
    kappa_unweighted_l95   = "95% CI",
    kappa_weighted         = "Kappa",
    kappa_weighted_l95     = "95% CI",
    brennan_prediger       = "Brennan–Prediger",
    brennan_prediger_l95   = "95% CI",
    observed_agreement     = "Obs. agreement (%)"
  ) |>
  # (optional) add spanners to visually group estimate + CI pairs
  tab_spanner("Unweighted", columns = c(kappa_unweighted, kappa_unweighted_l95)) |>
  tab_spanner("Weighted", columns = c(kappa_weighted, kappa_weighted_l95)) |>
  tab_spanner("Brennan–Prediger", columns = c(brennan_prediger, brennan_prediger_l95)) |>
  cols_align(align = "center", columns = -item) |>
  tab_header(title = md("**Table 5. Kappa estimates for the ODI items**")) |>
  tab_options(
    table.font.size = px(12),
    heading.title.font.size = px(14),
    column_labels.font.size = px(12),
    heading.align = "left") |> 
  tab_footnote(
    footnote = "Brennan & Prediger is similar to PABAK for polytomous items.",
    locations = cells_column_labels(columns = "brennan_prediger")
  ) |> 
  tab_footnote(
    footnote = "Quadratic weights (Fleiss-Cohen)",
    locations = cells_column_labels(columns = "kappa_weighted")
  )

kappa_gt
Table 5. Kappa estimates for the ODI items
Item
Unweighted
Weighted
Brennan–Prediger
Obs. agreement (%)
Kappa 95% CI Kappa1 95% CI Brennan–Prediger2 95% CI
osw1 0.05 (-0.05; 0.16) 0.56 (0.44; 0.67) 0.17 (0.08; 0.27) 0.31
osw2 0.13 (0.03; 0.24) 0.46 (0.32; 0.60) 0.23 (0.14; 0.33) 0.36
osw3 0.22 (0.11; 0.33) 0.52 (0.39; 0.66) 0.31 (0.22; 0.41) 0.43
osw4 0.10 (0.00; 0.19) 0.54 (0.44; 0.65) 0.17 (0.08; 0.27) 0.31
osw5 0.21 (0.11; 0.32) 0.55 (0.44; 0.66) 0.30 (0.20; 0.40) 0.42
osw6 0.16 (0.06; 0.27) 0.43 (0.30; 0.57) 0.26 (0.17; 0.36) 0.38
osw7 0.13 (0.02; 0.23) 0.47 (0.34; 0.60) 0.21 (0.13; 0.31) 0.35
osw8 0.30 (0.19; 0.41) 0.43 (0.27; 0.59) 0.41 (0.31; 0.51) 0.51
osw9 0.24 (0.13; 0.34) 0.53 (0.42; 0.64) 0.31 (0.22; 0.41) 0.43
osw10 0.18 (0.07; 0.28) 0.50 (0.37; 0.62) 0.28 (0.18; 0.38) 0.40
1 Quadratic weights (Fleiss-Cohen)
2 Brennan & Prediger is similar to PABAK for polytomous items.
Code
# ----- Generating table for osw1 only with all relevant values (used to generate function)

# # Item levels
# item_levels <- 0:5
# 
# # Matrix of osw1 as factors
# tab_osw1 <- reprod_data |>
#   select(osw1_1, osw1_2) |>
#   drop_na() |>
#   mutate(across(everything(),
#                 ~ factor(.x, levels = item_levels, ordered = TRUE))) |>
#   with(table(osw1_1, osw1_2))
# 
# # Kappa unweighted
# res_unw <- CohenKappa(tab_osw1, weights = "Unweighted",  conf.level = 0.95)
# 
# # Kappa weighted (quadratic)
# res_wsq <- DescTools::CohenKappa(tab_osw1, weights = "Fleiss-Cohen", conf.level = 0.95)
# 
# # Observed agreement & BP (Prediger) kappa (+ its CI)
# A  <- sum(diag(tab_osw1))                              # exact agreements
# n  <- sum(tab_osw1)                                    # total paired ratings
# po <- A / n                                            # observed agreement
# 
# k  <- nrow(tab_osw1)                                   # number of categories (should be 6)
# a  <- k / (k - 1)                                      # linear transform slope
# b  <- -1 / (k - 1)                                     # linear transform intercept
# 
# bp_kappa <- a * po + b                                 # BP point estimate
# 
# # CI for Po (Wilson), then transform endpoints to BP CI
# po_ci  <- DescTools::BinomCI(A, n, conf.level = 0.95, method = "wilson")
# bp_l95 <- a * po_ci[, "lwr.ci"] + b
# bp_u95 <- a * po_ci[, "upr.ci"] + b
# 
# bp_l95 <- pmax(-1, bp_l95) # clip to valid range
# bp_u95 <- pmin( 1, bp_u95)
# 
# # A table with all kappa values and observed agreement
# kappa_tbl <- tibble(
#   item                 = "osw1",
#   kappa_unweighted     = unname(res_unw["kappa"]),
#   kappa_weighted       = unname(res_wsq["kappa"]),   # quadratic (Fleiss–Cohen)
#   brennan_prediger     = bp_kappa,
#   observed_agreement   = po
# ) |>
#   mutate(across(where(is.numeric), ~ round(.x, 3)))
# 
# kappa_tbl

Questions

5.1 Table 5 shows both unweighted and weighted \(\kappa\) (with 95% confidence intervals) for the ODI items. Which version of \(\kappa\) is most appropriate to report in this case, and why?

ImportantAnswer

Use the weighted kappa as your primary estimate because the ODI item responses (0–5) are ordered categories where a 1-step disagreement (e.g., 2 vs 3) is less serious than a 3-step disagreement (e.g., 2 vs 5). Unweighted kappa treats all disagreements equally and is appropriate only for nominal categories or when you care about exact matches only.

5.2 Compare weighted and unweighted \(\kappa\) of item 1 (Pain intensity) and item 8 (Sex life, if relevant). Why do their (\(\kappa\)) estimates differ, and why do the weighted and unweighted versions behave differently?

Re-read the item wording and the study design in the exercise introduction.

ImportantAnswer

Item 1 (Pain) reflects a symptom that can change considerably over two weeks, especially in a mixed sample of acute and chronic patients. This lowers the agreement between test and retest and gives a low unweighted \(\kappa\). In contrast, item 8 (Sex life) often reflects a more stable aspect of function, leading to higher agreement.

Most disagreements on the pain item are small shifts between adjacent categories. Unweighted kappa treats these as full disagreements, but weighted \(\kappa\) gives partial credit and therefore increases the estimate. For item 8, disagreements are less frequent but sometimes larger jumps, which are penalized more strongly by the weighting.

Lastly, the population is a mix of patients seen in the primary and secondary sector, therefore both acute and chronic patients. With a test-retest period 2 weeks, it is likely that some patients are NOT stable with regards to pain, and this will lower the \(\kappa\). Contrary, the sexlife item may measure a more stable construct giving a higher \(\kappa\).

5.3 In Table 5, item 1 (Pain intensity) shows a very low unweighted \(\kappa\) with a modest observed agreement (~31%). Explain why this can happen for an ordinal 0–5 item, and how Brennan–Prediger \(\kappa\) helps interpret the result.

ImportantAnswer

With 6 categories, chance agreement is 1/6 \(\approx\) 16.7%. An observed agreement of 31% is only modestly above chance, so a low unweighted \(\kappa\) is expected, and therefore this is not a classic κ paradox (which is high observed agreement but low \(\kappa\) due to skewed margins). In cases of a classic κ paradox, Brennan-Prediger \(\kappa\) will typically be higher and more in line with the observed agreement, while weighted \(\kappa\) remains the preferred primary estimate for ordinal items.

5.4 How should you report your \(\kappa\) estimates?

ImportantAnswer

When reporting \(\kappa\) estimates, I suggest you follow the GRRAS and COSMIN guidelines. This should be repored as a minimum:

  • Context & design: raters/occasions, time interval (test–retest), target population, item scale and category levels (e.g., 0–5), handling of missing/“not relevant”
  • Metric choice: for ordinal 0–5 items, report weighted \(\kappa\) as primary and state the weighting scheme (linear vs quadratic/Fleiss–Cohen) and rationale; optionally add unweighted \(\kappa\) for exact-match agreement.
  • Estimates with uncertainty: give \(\kappa\) estimate with 95% CI and the CI method; also report observed agreement. Include the confusion matrix or sufficient margins so readers can judge prevalence in an appendix.
  • Prevalence/bias check: add Brennan–Prediger \(\kappa\) (polytomous items) or PABAK (dichotomous items)) alongside observed agreement to diagnose the \(\kappa\) paradox
  • Analysis details: software/package (e.g., R + package/version), weighting matrix, and any departures (e.g., bootstrap CI)

A researcher plans a test–retest reproducibility study. She’s been told that reliability “improves” with a more heterogeneous sample, so she intends to include very different patients.

Question

6.1 Is this a sound strategy? Discuss briefly.

ImportantAnswer

Reliability should be estimated in (and generalize to) the population where the instrument will be used. Deliberately adding extreme cases only to “boost” reliability is misleading.

Use the intended-use population, ensure clinical stability across a suitable retest interval, avoid interventions in between, and report both relative (ICC/\(\kappa\)) and absolute (SEM/LoA) indices with CIs.

To download the answers provided in this exercise, right-click on the page and choose ‘save as’. This saves a standalone html page and a folder with relevant html information. Both are required to open the html-page.

Download the ‘osw_reprod_10items.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
reprod_data <- read_rds("osw_reprod_10items.rds")

The R libraries used are these:

Code
library(knitr)      # For knitting nice html-files
library(tidyverse)  # For tidy data wrangling and more
library(broom)      # Turning output into tidy tibbles
library(gt)         # For tables
library(gtExtras)   # For tables - extra
library(psych)      # For reliability, ICC, Kappa and much more
library(DescTools)  # Used for Kappa, PABAK and CI's
library(here)       # For locating root folder
library(skimr)      # For skimming dataset