Field test exercise

Back to the main page

Field test

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

As part of your research investigating the effect of a multidisciplinary intervention for patients with chronic whiplash associated disorder (WAD) in patients seen in the primary and secondary sectors of the Danish health care system, you are continuing your work on the Neck Disability Index (NDI).

You have decided to perform a field test procedure on the NDI to see how the data structure looks like and how the items are performing. To do this, you look at the following properties:

  • Item characteristics
  • Internal consistency
  • Reliability
  • Floor and ceiling effect

The NDI

The NDI has 10 items (similar to the ODI), each item has 6 response options, and the scale range is 0-50 (high score equals high neck disability). It is based on a reflective model. You can view the NDI in full by clicking here:

Neck Disability Index

The dataset

First examine the dataset. A summary is provided below.

Code
# Generating data.frame for codebook

codebook_dta <- data.frame(
  Variable = c("idnr", "seen", "bafu", "sex", "age", "n01-n10", "NDI10", "stable"),
  Code = c("ID number",
           "1 = primary sector patients; 2 = secondary sector patients",
           "1 = baseline; 2 = 3 days or 2 weeks follow-up",
           "1 = male; 2 = female",
           "Age of the patients in years",
           "Neck Disability Index (NDI) items 1 - 10",
           "NDI sumscore (0-100), high score = high disability",
           "1 = better; 2 = no change; 3 = worse")
)

# Generating table with GT

(codebook_tbl <- codebook_dta %>%
  gt() %>%
  tab_header(
    title = "Data Codebook",
    subtitle = "Description of variables used in the study of NDI"
  ) %>%
  cols_label(
    Variable = "Variables",
    Code = "Description"
  ) %>%
  fmt_markdown(columns = Code) %>%
  tab_options(
    table.font.size = "small",
    heading.title.font.size = "large",
    heading.subtitle.font.size = "medium"
  ))
Data Codebook
Description of variables used in the study of NDI
Variables Description
idnr ID number
seen 1 = primary sector patients; 2 = secondary sector patients
bafu 1 = baseline; 2 = 3 days or 2 weeks follow-up
sex 1 = male; 2 = female
age Age of the patients in years
n01-n10 Neck Disability Index (NDI) items 1 - 10
NDI10 NDI sumscore (0-100), high score = high disability
stable 1 = better; 2 = no change; 3 = worse
Code
(summary <- skim(field_data)) # This will show a summary of the dataset
Data summary
Name field_data
Number of rows 652
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.13 101 319 613.50 695.00 776.00 ▃▂▂▃▇
seen 0 1.00 1.54 0.50 1 1 2.00 2.00 2.00 ▇▁▁▁▇
bafu 0 1.00 1.50 0.50 1 1 1.50 2.00 2.00 ▇▁▁▁▇
sex 72 0.89 1.62 0.49 1 1 2.00 2.00 2.00 ▅▁▁▁▇
age 72 0.89 44.12 13.52 16 35 42.69 54.05 84.83 ▂▇▅▃▁
n01 90 0.86 2.15 1.02 0 1 2.00 3.00 5.00 ▅▇▅▂▁
n02 92 0.86 0.82 0.94 0 0 1.00 1.00 5.00 ▇▂▁▁▁
n03 89 0.86 1.54 1.39 0 0 1.00 3.00 5.00 ▇▂▂▂▁
n04 89 0.86 1.63 1.26 0 1 1.00 3.00 5.00 ▇▃▃▁▁
n05 91 0.86 2.20 1.61 0 1 2.00 3.00 5.00 ▇▃▆▂▂
n06 91 0.86 1.12 1.08 0 0 1.00 2.00 4.00 ▇▇▅▂▁
n07 98 0.85 1.72 1.49 0 0 1.00 3.00 5.00 ▇▃▃▁▁
n08 111 0.83 1.67 1.30 0 1 1.00 3.00 5.00 ▇▃▃▁▁
n09 91 0.86 1.62 1.25 0 1 1.00 2.00 5.00 ▇▃▂▁▁
n10 98 0.85 2.16 1.50 0 1 2.00 3.00 5.00 ▇▅▃▂▂
NDI10 88 0.87 33.30 19.39 0 18 30.00 48.00 91.11 ▆▇▆▃▁
stable 190 0.71 1.71 0.60 1 1 2.00 2.00 3.00 ▆▁▇▁▁

Start with the questions in tab ‘1. Item characteristics’ 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.

Item scores

First, you decide to look at specific charateristics of the individual NDI items at baseline. To do this, you generate Table 1 showing n, mean, median, and missings for each item.

Code
# Generating data for table 1.
table1_data <- field_data %>%
  filter(bafu == 1) %>% 
  select(n01:n10) %>% 
  pivot_longer(cols = everything()) %>% 
  rename(item = name) %>% 
  group_by(item) %>% 
  summarise(
    n = sum(!is.na(value)),
    mean = round(mean(value, na.rm = TRUE), 2),
    median = median(value, na.rm = TRUE),
    missing = sum(is.na(value)),
    missing_pct = round((missing/(missing + n)) * 100, 2)
    )

# Generating item description vector

description <- tibble(description = c(
  "Pain intensity",
  "Personal care",
  "Lifting",
  "Reading",
  "Headache",
  "Concentration",
  "Work",
  "Driving",
  "Sleep",
  "Recreation"
))

# Attaching and relocating description vector
table1_data <- cbind(description, table1_data) %>% 
  relocate(description, .after = item) %>% 
  rename(
    Item = item,
    Description = description
    )

# Generating and printing Table 1
(table1 <- gt(table1_data) %>% 
  cols_align(
    align = "center",
    columns = everything()
    ) %>% 
  cols_label(
    missing = "missing (n)",
    missing_pct = "missing (%)"
  ) %>% 
  tab_header(
    title = md("**Table 1. NDI item stats at baseline**")
  ) %>% 
  tab_options(
    table.font.size = px(14),
    table.align = "left",
    table.border.top.color = "transparent", # Remove top border around table
     data_row.padding = px(3) # Reduce the height of rows
    ))
Table 1. NDI item stats at baseline
Item Description n mean median missing (n) missing (%)
n01 Pain intensity 324 2.39 2 2 0.61
n02 Personal care 325 0.95 1 1 0.31
n03 Lifting 326 1.65 1 0 0.00
n04 Reading 325 1.76 2 1 0.31
n05 Headache 325 2.40 3 1 0.31
n06 Concentration 324 1.19 1 2 0.61
n07 Work 319 1.84 2 7 2.15
n08 Driving 309 1.83 2 17 5.21
n09 Sleep 325 1.78 2 1 0.31
n10 Recreation 319 2.35 2 7 2.15

Question

1.1 Describe your findings (category frequency, item skewness and kurtosis) and discuss what they mean and how to interpret them.

Item distribution

Then you decide to look at the distribution of answers for each item. Therefore you have generated Table 2 showing the distribution of answers in each category (%) for each item. You also included missings, skewness and kurtosis.

Code
# Generating item categories percentages
table2_data <- field_data %>% 
  filter(bafu == 1) %>% 
  select(n01:n10) %>% 
  pivot_longer(
    cols = everything()
    ) %>% 
  rename(item = name) %>% 
  group_by(item, value) %>% 
  summarise(
    n = n(),
    .groups = "drop"
  ) |> 
  pivot_wider(
    names_from = "value",
    values_from = "n",
    values_fill = 0
  ) %>% 
  mutate(item_sum = rowSums(across(where(is.numeric)))) %>% 
  mutate(
    Cat0 = round(((`0`/item_sum)*100), 1),
    Cat1 = round(((`1`/item_sum)*100), 1),
    Cat2 = round(((`2`/item_sum)*100), 1),
    Cat3 = round(((`3`/item_sum)*100), 1),
    Cat4 = round(((`4`/item_sum)*100), 1),
    Cat5 = round(((`5`/item_sum)*100), 1),
    Missing = round(((`NA`/item_sum)*100), 2)
  ) %>% 
  select(item, Cat0:Missing)

# Generating Skewness and Kurtosis vector
kur_skew <- select(field_data, n01:n10) %>% 
  describe(type=3, na.rm = TRUE) %>% 
  mutate(
    Skewness = round(skew, 2),
    Kurtosis = round(kurtosis, 2)
  ) %>% 
  select(Skewness, Kurtosis)

# See: https://rcompanion.org/handbook/C_02.html for interpretation

# Attaching and relocating description vector
table2_data_all <- cbind(description, table2_data, kur_skew) %>% 
  relocate(description, .after = item) %>% 
  rename(
    Item = item,
    Description = description
    )

# Selecting item numbers
item_no <- table2_data_all %>% 
  select(Item)

item_no_drop <- table2_data_all %>% 
  subset(Item!="n05") %>% 
  select(Item)

# Generating and printing Table 2 with GT
(table2 <- gt(table2_data_all) %>% 
  cols_align(
    align = "center",
    columns = c(-"Description", -"Item")
  ) %>% 
  tab_header(
    title = md("**Table 2. Distribution of response options including skewness and kurtosis**")
  ) %>% 
  opt_align_table_header(
    align = "left"
  ) %>% 
  cols_label(
    Cat0 = "Cat0 (%)",
    Cat1 = "Cat1 (%)",
    Cat2 = "Cat2 (%)",
    Cat3 = "Cat3 (%)",
    Cat4 = "Cat4 (%)",
    Cat5 = "Cat5 (%)",
    Missing = "Missing (%)"
  ) %>% 
  tab_options(
    table.font.size = px(14),
    table.align = "left",
    table.border.top.color = "transparent", # Remove top border around table
     data_row.padding = px(3) # Reduce the height of rows
    ))
Table 2. Distribution of response options including skewness and kurtosis
Item Description Cat0 (%) Cat1 (%) Cat2 (%) Cat3 (%) Cat4 (%) Cat5 (%) Missing (%) Skewness Kurtosis
n01 Pain intensity 2.5 13.2 42.9 27.9 9.8 3.1 0.61 0.33 0.09
n02 Personal care 38.3 33.4 23.3 3.7 0.6 0.3 0.31 1.02 0.83
n03 Lifting 19.3 39.9 12.9 14.1 11.7 2.1 0.00 0.72 -0.55
n04 Reading 19.0 25.5 22.4 26.7 5.5 0.6 0.31 0.25 -1.01
n05 Headache 16.9 15.6 13.8 30.4 10.1 12.9 0.31 0.15 -1.07
n06 Concentration 31.9 33.4 19.6 11.7 2.8 0.0 0.61 0.78 -0.16
n07 Work 23.9 21.8 18.4 21.2 5.2 7.4 2.15 0.59 -0.55
n08 Driving 16.9 25.8 20.2 23.6 5.2 3.1 5.21 0.40 -0.66
n09 Sleep 15.3 31.6 24.2 17.8 9.2 1.5 0.31 0.51 -0.57
n10 Recreation 7.4 27.9 21.2 16.9 13.8 10.7 2.15 0.40 -0.89

Question

1.2 Describe your findings and discuss what they mean.

Next you look at internal consistency of the NDI, and you choose to calculate Cronbach’s Alpha.

Raw Alpha: Is calculated using covariances. Used if the metric of the response options is the same in your unidimensional scale.

Standardised Alpha: Is calculated using the correlations among items. Is based on the assumption that all of the items have equal variances (mean = 0, SD (or z-score) = 1). It is used when the response option of your questions change in your unidimensional scale (e.g. different number of response options or different wording).

Cronbach’s Alpha (raw and standardised) for the NDI is reported in Table 3:

Code
# Generating dataset
alpha_data <- field_data %>% 
  filter(bafu == 1) %>% 
  select(n01:n10)

# Generating alpha results
alpha_results <- alpha(alpha_data)

# Extracting important results for Table 3 including CIs
main_results <- data.frame(
  raw_alpha = round(alpha_results$total$raw_alpha, 2),
  ci_lower = round(alpha_results$feldt$lower.ci, 2),
  ci_upper = round(alpha_results$feldt$upper.ci, 2),
  "Standardised Alpha" = round(alpha_results$total$std.alpha, 2),
  "Guttmann's Lambda 6" = round(alpha_results$total$`G6(smc)`, 2),
  "Avg inter-item corr" = round(alpha_results$total$average_r, 2)
)

names(main_results) <- c("Raw Alpha", "Lower CI raw", "Upper CI raw", 
                         "Standardised Alpha", "Guttmann's Lambda 6", 
                         "Avg inter-item corr")

# Define a function to extract standardized alpha CI's
std_alpha_func <- function(data, indices) {
  sample_data <- data[indices, ]                # Step 1: Subset the data using the indices
  alpha_results <- psych::alpha(sample_data)    # Step 2: Calculate Cronbach's alpha using the psych package
  return(alpha_results$total$std.alpha)         # Step 3: Return the standardized alpha value
}

# Perform bootstrapping (500 samples)
boot_results <- boot(data = alpha_data, statistic = std_alpha_func, R = 500)

# Get the 95% CI for standardized alpha
std_alpha_ci <- round(boot.ci(boot_results, type = "perc")$percent[4:5], 2)

# Create a tibble for the Standardised Alpha CIs
std_alpha_ci <- tibble(
  Std_Alpha_Lower_CI = std_alpha_ci[1],
  Std_Alpha_Upper_CI = std_alpha_ci[2]
)

# Renaming CI's in tibble
std_alpha_ci <- std_alpha_ci %>%
  rename(
    "Lower CI std" = Std_Alpha_Lower_CI,
    "Upper CI std" = Std_Alpha_Upper_CI
  )

# Combining CI's with main_results and relocating
main_results <- cbind(main_results, std_alpha_ci) %>% 
  relocate("Lower CI std", .after = "Standardised Alpha") |> 
  relocate("Upper CI std", .after = "Lower CI std")

# Generating and printing Table 3 with GT
(table3 <- gt(main_results) %>% 
  cols_align(
    align = "center",
    columns = everything()
  ) %>% 
  tab_header(
    title = md("**Table 3. Cronbach's Alpha (CI's) for the NDI at baseline**")
  ) %>% 
  opt_align_table_header(
    align = "left"
  ) %>% 
  tab_options(
    table.font.size = px(14),
    table.align = "left",
    table.border.top.color = "transparent", # Remove top border around table
     data_row.padding = px(3) # Reduce the height of rows
    ))
Table 3. Cronbach’s Alpha (CI’s) for the NDI at baseline
Raw Alpha Lower CI raw Upper CI raw Standardised Alpha Lower CI std Upper CI std Guttmann's Lambda 6 Avg inter-item corr
0.88 0.86 0.9 0.89 0.87 0.91 0.89 0.44

Question

2.1 Describe how you would interpret the results of your output. Which Alpha should be used with the NDI?

Now you turn to Alpha at item level. You calculate this and get the results in Table 4:

Code
# Raw alpha, std. alpha, avg. inter-item corr
alpha_item <- round(alpha_results[["alpha.drop"]], 2) %>% 
  select(raw_alpha, std.alpha, average_r) %>% 
  rename(
    "raw alpha" = raw_alpha,
    "standardised alpha" = std.alpha,
    "inter-item corr." = average_r
  )

# n, item-test corr., item-rest corr.
item_stats <- round(alpha_results[["item.stats"]], 2) %>% 
  select(n, raw.r, r.drop) %>% 
  rename(
    obs = n,
    "item-test corr." = "raw.r",
    "item-rest corr." = "r.drop"
  )

# Combining data for Table 4
table4_data <- cbind(item_no, description, alpha_item, item_stats) %>% 
  relocate(obs, .before = "raw alpha") %>% 
  relocate("inter-item corr.", .after = "item-rest corr.")

# Generating and printing Table 4 with GT
(table4 <- gt(table4_data) %>% 
  cols_align(
    align = "center",
    columns = c(-description)
  ) %>% 
  cols_label(
    description = "Description",
    obs = "N",
    "raw alpha" = "Raw alpha",
    "standardised alpha" = "Standardised alpha",
    "item-test corr." = "Item-test corr.",
    "item-rest corr." = "Item-rest corr.",
    "inter-item corr." = "Inter-item corr."
  ) %>% 
  tab_header(
    title = md("**Table 4. Cronbach's Alpha at item level**")
  ) %>% 
  opt_align_table_header(
    align = "left"
  ) %>% 
  tab_options(
    table.font.size = px(14),
    table.align = "left",
    table.border.top.color = "transparent", # Remove top border around table
     data_row.padding = px(3) # Reduce the height of rows
    ))
Table 4. Cronbach’s Alpha at item level
Item Description N Raw alpha Standardised alpha Item-test corr. Item-rest corr. Inter-item corr.
n01 Pain intensity 324 0.87 0.88 0.66 0.59 0.45
n02 Personal care 325 0.87 0.88 0.72 0.66 0.44
n03 Lifting 326 0.87 0.88 0.74 0.66 0.44
n04 Reading 325 0.87 0.88 0.73 0.65 0.44
n05 Headache 325 0.89 0.90 0.49 0.34 0.49
n06 Concentration 324 0.87 0.88 0.72 0.65 0.44
n07 Work 319 0.86 0.87 0.80 0.73 0.43
n08 Driving 309 0.86 0.87 0.75 0.67 0.44
n09 Sleep 325 0.87 0.88 0.67 0.58 0.45
n10 Recreation 319 0.86 0.87 0.78 0.71 0.43

Questions

2.2 Describe your findings from the output of Table 4 and discuss what they mean

2.3 Should we remove an item? If so, which one(s)?

2.4 If you believe one or more items should be removed, what do you expect the results will be?

You now decide to run a new analyses with item 5 (headache) removed and look at the overall Alpha and Alpha at item level. This is presented in Table 5 and Table 6.

Code
# Generating alpha results without item 5
alpha_data_drop <- alpha_data %>% 
  select(-n05)
alpha_results_drop <- alpha(alpha_data_drop)

# Generating alpha results without item 5
alpha_results <- alpha(alpha_data)

# Extracting important results for Table 5 including CIs
main_results_drop <- data.frame(
  raw_alpha = round(alpha_results_drop$total$raw_alpha, 2),
  ci_lower = round(alpha_results_drop$feldt$lower.ci, 2),
  ci_upper = round(alpha_results_drop$feldt$upper.ci, 2),
  "Standardised Alpha" = round(alpha_results_drop$total$std.alpha, 2),
  "Guttmann's Lambda 6" = round(alpha_results_drop$total$`G6(smc)`, 2),
  "Avg inter-item corr" = round(alpha_results_drop$total$average_r, 2)
)

names(main_results_drop) <- c("Raw Alpha", "Lower CI raw", "Upper CI raw", 
                         "Standardised Alpha", "Guttmann's Lambda 6", 
                         "Avg inter-item corr")

# Perform bootstrapping (500 samples)
boot_results_drop <- boot(data = alpha_data_drop, statistic = std_alpha_func, R = 500)

# Get the 95% CI for standardized alpha
std_alpha_ci_drop <- round(boot.ci(boot_results_drop, type = "perc")$percent[4:5], 2)

# Create a tibble for the Standardised Alpha CIs
std_alpha_ci_drop <- tibble(
  Std_Alpha_Lower_CI = std_alpha_ci_drop[1],
  Std_Alpha_Upper_CI = std_alpha_ci_drop[2]
)

# Renaming CI's in tibble
std_alpha_ci_drop <- std_alpha_ci_drop %>%
  rename(
    "Lower CI std" = Std_Alpha_Lower_CI,
    "Upper CI std" = Std_Alpha_Upper_CI
  )

# Combining CI's with main_results and relocating
main_results_drop <- cbind(main_results_drop, std_alpha_ci_drop) %>% 
  relocate("Lower CI std", .after = "Standardised Alpha") |> 
  relocate("Upper CI std", .after = "Lower CI std")

# Generating and printing Table 5 with GT
(table5 <- gt(main_results_drop) %>% 
  cols_align(
    align = "center",
    columns = everything()
  ) %>% 
  tab_header(
    title = md("**Table 5. Cronbach's Alpha for the NDI at baseline without item 5 (headache)**")
  ) %>% 
  opt_align_table_header(
    align = "left"
  ) %>% 
  tab_options(
    table.font.size = px(14),
    table.align = "left",
    table.border.top.color = "transparent", # Remove top border around table
     data_row.padding = px(3) # Reduce the height of rows
    ))
Table 5. Cronbach’s Alpha for the NDI at baseline without item 5 (headache)
Raw Alpha Lower CI raw Upper CI raw Standardised Alpha Lower CI std Upper CI std Guttmann's Lambda 6 Avg inter-item corr
0.89 0.88 0.91 0.9 0.88 0.91 0.89 0.49
Code
# Raw alpha, std. alpha, avg. inter-item corr
alpha_item_drop <- round(alpha_results_drop[["alpha.drop"]], 2) %>% 
  select(raw_alpha, std.alpha, average_r) %>% 
  rename(
    "raw alpha" = raw_alpha,
    "standardised alpha" = std.alpha,
    "inter-item corr." = average_r
  )

# n, item-test corr., item-rest corr.
item_stats_drop <- round(alpha_results_drop[["item.stats"]], 2) %>% 
  select(n, raw.r, r.drop) %>% 
  rename(
    obs = n,
    "item-test corr." = "raw.r",
    "item-rest corr." = "r.drop"
  )

# Generating description without item 5
description_drop <- tibble(description_drop = c(
  "Pain intensity",
  "Personal care",
  "Lifting",
  "Reading",
  "Concentration",
  "Work",
  "Driving",
  "Sleep",
  "Recreation"
  ))

# Generating table 6 data
table6_data <- cbind(item_no_drop, description_drop, alpha_item_drop, item_stats_drop) %>% 
  relocate(obs, .before = "raw alpha") %>% 
  relocate("inter-item corr.", .after = "item-rest corr.")

# Generating and printing Table 6 with GT
(table6 <- gt(table6_data) %>% 
  cols_align(
    align = "center",
    columns = c(-Item, -description_drop)
  ) %>% 
  cols_label(
    obs = "N",
    "raw alpha" = "Raw alpha",
    "standardised alpha" = "Standardised alpha",
    "item-test corr." = "Item-test corr.",
    "item-rest corr." = "Item-rest corr.",
    "inter-item corr." = "Inter-item corr."
  ) %>% 
  tab_header(
    title = md("**Table 6. Cronbach's Alpha at item level without item 5 (headache)**")
  ) %>% 
  opt_align_table_header(
    align = "left"
  ) %>% 
  tab_options(
    table.font.size = px(14),
    table.align = "left",
    table.border.top.color = "transparent", # Remove top border around table
     data_row.padding = px(3) # Reduce the height of rows
    ))
Table 6. Cronbach’s Alpha at item level without item 5 (headache)
Item description_drop N Raw alpha Standardised alpha Item-test corr. Item-rest corr. Inter-item corr.
n01 Pain intensity 324 0.89 0.89 0.67 0.59 0.50
n02 Personal care 325 0.88 0.88 0.74 0.68 0.49
n03 Lifting 326 0.88 0.88 0.77 0.68 0.49
n04 Reading 325 0.88 0.89 0.73 0.64 0.49
n06 Concentration 324 0.89 0.89 0.69 0.60 0.50
n07 Work 319 0.88 0.88 0.81 0.74 0.48
n08 Driving 309 0.88 0.88 0.77 0.69 0.49
n09 Sleep 325 0.89 0.89 0.68 0.58 0.51
n10 Recreation 319 0.88 0.88 0.81 0.74 0.48

Question

2.5 Explain your findings of the scale-level and item-level Cronbach’s Alpha (standardised) when item 5 is removed.

Now you turn to reliability and want to calculate the test-retest ICC(2.1) for the full 10-item NDI and the 9-item NDI (-headache question) to see how the two scales perform.

Code
# Generating dataset of stable patients for calculating ICC

icc_data_all <- field_data |> 
  filter(stable == 2) |> 
  select(idnr, bafu, NDI10)

# Wide format
icc_data_all_wide <- pivot_wider(icc_data_all,
                                 id_cols = idnr,
                                 names_from = bafu,
                                 values_from = NDI10) |> 
  rename(
    measurement1 = "1",
    measurement2 = "2"
  ) |> 
  select(-idnr)
  
icc_results_all <- ICC(icc_data_all_wide, lmer=TRUE)

# Generating Table 7
icc_table7 <- data.frame(
  ICC_Type = rownames(icc_results_all$results),
  ICC_Value = icc_results_all$results[, "ICC"],
  Lower_CI = icc_results_all$results[, "lower bound"],
  Upper_CI = icc_results_all$results[, "upper bound"]
)

# Generating Shrout & Fleiss labels
icc_shrout <- tibble(icc_shrout = c(
  "ICC(1.1)",
  "ICC(2.1)",
  "ICC(3.1)",
  "ICC(1.k)",
  "ICC(2.k)",
  "ICC(3.k)"
))

# Attaching labels to Tabel 7
icc_table7 <- cbind(icc_table7, icc_shrout) %>% 
  relocate(icc_shrout, .before = "ICC_Type")

# The output of ICC from the psych package is a little hard to interpret 
# as not all formulas are included. We # need to use our knowledge that some 
# of the formulas are the same. According to Shrout & Fleiss (1979), and the output should be
# interpreted as follows:

# ICC1 = One-way random effects model, single rater, agreement = ICC(1,1)
# ICC1k = One-way random effects model, average rater, agreement = ICC(1,k)

# ICC2 = Two-way random effects model, single rater, agreement = ICC(2,1)
# ICC2k = Two-way random effects model, average rater, agreement = ICC(2,k)

# ICC3 = Two-way mixed effects model, single rater, consistency = ICC(3,1)
# ICC3k = Two-way mixed effects model, average rater, consistency = ICC(3,k)

# Generating ICC table 7
(icc_table7 <- gt(icc_table7) %>%
  tab_header(
    title = "Table 7. Intraclass Correlation Coefficients for NDI10",
    subtitle = "With Confidence Intervals (n = 127)"
  ) %>%
  fmt_number(
    columns = c("ICC_Value", "Lower_CI", "Upper_CI"),
    decimals = 2
  ) %>%
  cols_label(
    icc_shrout = "ICC Type",
    ICC_Type = "Description",
    ICC_Value = "ICC Value",
    Lower_CI = "Lower CI",
    Upper_CI = "Upper CI"
  ))
Table 7. Intraclass Correlation Coefficients for NDI10
With Confidence Intervals (n = 127)
ICC Type Description ICC Value Lower CI Upper CI
ICC(1.1) Single_raters_absolute 0.91 0.88 0.94
ICC(2.1) Single_random_raters 0.91 0.88 0.94
ICC(3.1) Single_fixed_raters 0.91 0.88 0.94
ICC(1.k) Average_raters_absolute 0.95 0.93 0.97
ICC(2.k) Average_random_raters 0.95 0.93 0.97
ICC(3.k) Average_fixed_raters 0.95 0.94 0.97
Code
# Generating NDI9 sumscore (leaving out item 5 (headache)) and using proportional recalculation method
icc_data_ndi9 <- field_data |> select(-c(n05, seen, sex, age)) |> 
  mutate(
    missing_count = rowSums(is.na(across(n01:n10))),
    NDI9_raw = rowSums(across(n01:n10), na.rm = TRUE),
    NDI9 = if_else(
      missing_count >= 3,
      NA_real_, # Set to NA when 3 or more items are missing
      (NDI9_raw/(45-(missing_count * 5)))*100 # Proportional recalculation of NDI09
    )
) |> 
  filter(stable == 2) |> 
  select(idnr, bafu, NDI9)

# sum(is.na(icc_data_ndi9$NDI9)) Code for checking how many missings are in NDI9

# Wide format
icc_data_ndi9_wide <- pivot_wider(icc_data_ndi9,
                                 id_cols = idnr,
                                 names_from = bafu,
                                 values_from = NDI9) |> 
  rename(
    measurement1 = "1",
    measurement2 = "2"
  ) |> 
  select(-idnr)
  
icc_results_ndi9 <- ICC(icc_data_ndi9_wide, lmer=TRUE)

# Generating Table 8
icc_table8 <- data.frame(
  ICC_Type = rownames(icc_results_ndi9$results),
  ICC_Value = icc_results_ndi9$results[, "ICC"],
  Lower_CI = icc_results_ndi9$results[, "lower bound"],
  Upper_CI = icc_results_ndi9$results[, "upper bound"]
)

# Attaching labels to Tabel 8
icc_table8 <- cbind(icc_table8, icc_shrout) %>% 
  relocate(icc_shrout, .before = "ICC_Type")

# Generating ICC table 8
(icc_table8 <- gt(icc_table8) %>%
  tab_header(
    title = "Table 8. Intraclass Correlation Coefficients for NDI9 (-headache item)",
    subtitle = "With Confidence Intervals (n=127)"
  ) %>%
  fmt_number(
    columns = c("ICC_Value", "Lower_CI", "Upper_CI"),
    decimals = 2
  ) %>%
  cols_label(
    icc_shrout = "ICC Type",
    ICC_Type = "Description",
    ICC_Value = "ICC Value",
    Lower_CI = "Lower CI",
    Upper_CI = "Upper CI"
  ))
Table 8. Intraclass Correlation Coefficients for NDI9 (-headache item)
With Confidence Intervals (n=127)
ICC Type Description ICC Value Lower CI Upper CI
ICC(1.1) Single_raters_absolute 0.90 0.87 0.93
ICC(2.1) Single_random_raters 0.90 0.87 0.93
ICC(3.1) Single_fixed_raters 0.90 0.87 0.93
ICC(1.k) Average_raters_absolute 0.95 0.93 0.96
ICC(2.k) Average_random_raters 0.95 0.93 0.96
ICC(3.k) Average_fixed_raters 0.95 0.93 0.96

Questions

3.1 The analysis includes n = 127 patients. Discuss what is important when selecting the test-retest period and patients in this population?

3.2 Describe the ICC(2.1) in Table 7 and 8 and discuss what they mean.

Lastly, you decide to have a look at floor and ceiling effects of the NDI10 using the both the conventional and scale width methods. Using the conventional method you get the results shown in Table 9.

Code
# Generating dataset for showing NDI total score and frequencies <= 20 and >= 80
fc_conventional <- field_data %>% 
  filter(bafu==1) %>% 
  mutate(NDI_total = round(NDI10, 2)) %>% 
  group_by(NDI_total) %>% 
  summarise(n = n()) %>% 
  mutate(pct = round((n/sum(n)*100), 2)) %>% 
  filter(NDI_total >= 80 | NDI_total <= 20)

# Generating and printing Table 9 with GT
(table9 <- gt(fc_conventional) %>% 
  cols_align(
    align = "center",
    columns = everything()
  ) %>% 
  cols_label(
    NDI_total = "NDI-sumscore",
    n = "N",
    pct = "Percentage"
  ) %>% 
  tab_header(
    title = md("**Table 9. Frequency of NDI-sumscore <= 20 and >= 80**")
  ) %>% 
  opt_align_table_header(
    align = "left"
  ) %>% 
    tab_footnote(
      footnote = "Total NDI-sumscores above 91.11 are not found and therefore not shown",
      locations = cells_column_labels(
        columns = NDI_total
      )
    ) %>% 
  tab_options(
    table.font.size = px(14),
    table.align = "left",
    table.border.top.color = "transparent", # Remove top border around table
     data_row.padding = px(3) # Reduce the height of rows
    ) |> 
  # Step 3: Add bold bottom border after the row where NDI_total is 20
  tab_style(
    style = cell_borders(
      sides = "bottom", 
      color = "black", 
      weight = px(3)  # Increase the weight to make it bold
    ),
    locations = cells_body(
      rows = NDI_total == 20  # Apply this style to the row with score 20
    )
  ))
Table 9. Frequency of NDI-sumscore <= 20 and >= 80
NDI-sumscore1 N Percentage
0.00 1 0.31
2.00 1 0.31
4.00 6 1.84
6.00 3 0.92
8.00 1 0.31
10.00 3 0.92
11.11 1 0.31
12.00 6 1.84
14.00 11 3.37
16.00 10 3.07
18.00 8 2.45
20.00 17 5.21
80.00 2 0.61
86.00 1 0.31
88.89 1 0.31
91.11 1 0.31
1 Total NDI-sumscores above 91.11 are not found and therefore not shown

Questions

4.1 What is the floor and ceiling effects of NDI10 using the conventional method?

4.2 Explain what floor and ceiling effects mean?

Now you calculate the floor and ceiling effects for the NDI10 using the scale width method. First you generate a Bland & Altman plot - see Figure 1.

Code
# Generating the dataset for the B&A plot
ba_data <- field_data %>%
  select(idnr, bafu, NDI10, stable) %>%
  filter(stable == 2) %>% 
  select(-stable) %>% 
  pivot_wider(names_from = bafu, values_from = NDI10) %>%
  rename(
    baseline = "1",
    follow_up = "2"
  )

# Pulling relevant data for B&A plot
baseline <- ba_data %>% pull(baseline)
follow_up <- ba_data %>% pull(follow_up)

# Bland and Altman plot data
blandr_stats <- blandr.statistics(baseline, follow_up)

# Drawing Figure 1. Bland & Altman plot for baseline and follow-up of NDI

bland_plot <- blandr.plot.ggplot(blandr_stats, plotTitle = "Figure 1. Bland & Altman plot of NDI10") +
  xlab("Mean of the two measurements") +
  ylab("Difference between the two measurements") +
  labs(caption = "Note: Green and red bands = CI for upper and lower LOA; Purple band = CI for the mean difference") +
  theme(plot.caption = element_text(hjust = 0)) +
  scale_x_continuous(breaks = seq(floor(min(blandr_stats$mean)/5)*5, ceiling(max(blandr_stats$mean)/5)*5, by = 5)) +  # Include min and 0, steps of 5
  scale_y_continuous(breaks = seq(floor(min(blandr_stats$diff)/5)*5, ceiling(max(blandr_stats$diff)/5)*5, by = 5))    # Include min and 0, steps of 5

bland_plot

Questions

4.3 Discuss how you interpret a Bland & Altman plot like this?

4.4 Determine the rough measurement error of NDI10 from the plot?

4.5 There are two outliers at the bottom of the plot in Figure 1. Discuss if they should be excluded?

Next, you extract the key data from the Bland & Altman plot and enter it into Table 10.

Code
# Generating data.frame of important B&A plot data
blandr1 <- data.frame(
  no.of.observations   = blandr_stats$no.of.observations,  # Element 20
  bias                = blandr_stats$bias,                # Element 7
  biasLowerCI         = blandr_stats$biasLowerCI,         # Element 9
  biasUpperCI         = blandr_stats$biasUpperCI,         # Element 8
  upperLOA            = blandr_stats$upperLOA,            # Element 13
  upperLOA_lowerCI    = blandr_stats$upperLOA_lowerCI,    # Element 15
  upperLOA_upperCI    = blandr_stats$upperLOA_upperCI,    # Element 14
  lowerLOA            = blandr_stats$lowerLOA,            # Element 16
  lowerLOA_lowerCI    = blandr_stats$lowerLOA_lowerCI,    # Element 18
  lowerLOA_upperCI    = blandr_stats$lowerLOA_upperCI     # Element 17
) %>%
  mutate_if(is.numeric, round, digits = 2)  # Round numeric values to 2 decimal places


# Generating Table 10 of important B&A plot data with GT
(table10 <- gt(blandr1) %>% 
  cols_align(
    align = "center",
    columns = everything()
  ) %>% 
  cols_label(
    no.of.observations = "N",
    bias = "Mean diff.",
    biasLowerCI = "CI-lower",
    biasUpperCI = "CI-upper",
    upperLOA = "Upper-LOA",
    upperLOA_lowerCI = "CI-lower",
    upperLOA_upperCI = "CI-upper",
    lowerLOA = "Lower-LOA",
    lowerLOA_lowerCI = "CI-lower",
    lowerLOA_upperCI = "CI-upper"
  ) %>% 
  tab_header(
    title = md("**Table 10. Data from the Bland & Altman plot in Figure 1**")
  ) %>% 
  opt_align_table_header(
    align = "left"
  ) %>% 
    tab_footnote(
      footnote = "Mean difference",
      locations = cells_column_labels(
        columns = bias
      )
    ) %>% 
  tab_footnote(
    footnote = "Confidence interval",
    locations = cells_column_labels(
      columns = c(biasLowerCI, biasUpperCI, upperLOA_lowerCI, upperLOA_upperCI, lowerLOA_lowerCI, lowerLOA_upperCI)
    )
  ) %>% 
  tab_footnote(
    footnote = "Limits of agreement",
    locations = cells_column_labels(
      columns = c(upperLOA, lowerLOA)
    )
  ) %>% 
  tab_options(
    table.font.size = px(14),
    table.align = "left",
    table.border.top.color = "transparent", # Remove top border around table
     data_row.padding = px(3) # Reduce the height of rows
    ))
Table 10. Data from the Bland & Altman plot in Figure 1
N Mean diff.1 CI-lower2 CI-upper2 Upper-LOA3 CI-lower2 CI-upper2 Lower-LOA3 CI-lower2 CI-upper2
127 1.24 -0.19 2.67 17.22 14.76 19.67 -14.74 -17.19 -12.29
1 Mean difference
2 Confidence interval
3 Limits of agreement

Questions

4.6 What is the exact measurement error of NDI10?

4.7 The number of participants in the study = 326. What is the floor and ceiling effects of NDI10 using the scale width method?

Apply the measurement error found in the Bland & Altman plot (Table 10) to Table 9 to calculate the floor and ceiling effects.

4.8. Discuss the findings from using both the conventional and scale width methods. Which method do you consider to be the best?

To download the answers provided to this exercise you need to open the html-file with the answers - see instructions in that file.

You can download the ‘field_test_data.dta’ (Stata format) 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
field_data <- read_stata(here("files", "02_advanced_course", "day2", "exercises", "field_test", "field_test_data.dta"))
field_data <- rename(field_data, 
  n01 = n1, 
  n02 = n2,
  n03 = n3,
  n04 = n4,
  n05 = n5,
  n06 = n6,
  n07 = n7,
  n08 = n8,
  n09 = n9
) |>              # remove all labels and attributes 
  zap_label() |> 
  zap_labels() |> 
  zap_formats() |> 
  zap_widths()

The R libraries used are these:

Code
library(knitr)      # For knitting nice html-files
library(tidyverse)
library(ggplot2)    # For nice plots
library(blandr)     # For Bland & Altman plots
library(gt)         # For tables
library(gtExtras)   # For tables - extra
library(haven)      # Importing dta datasets
library(psych)      # For various clinimetric calculations
library(boot)       # For bootstrapping CI's
library(here)       # For locating root folder
library(skimr)      # For skimming dataset