Calculate CI for chi-squared of the Friedman test in R I have a dataset (not normal distribution) with repeated measures over time. As such I was planning to use the Friedman.test in R:
friedman.test(dash ~ time | nr)

this gave:

Friedman rank sum test
data: dash and time and nr Friedman chi-squared = 105.26, df = 2, p-value < 2.2e-16

To calculate the CI of the chi-squared I tried the following:
friedman_boot <- function(data, indices) {
  return(friedman.test(dash ~ time | nr, data = data_t[indices, ])$statistic)
}

boot_results <- boot(data = data_t, statistic = friedman_boot, R = 1000)

boot_ci <- boot.ci(boot.out = boot_results, type = "perc", conf = 0.95)

boot_ci

which gave:
boot_results <- boot(data = data_t, statistic = friedman_boot, R = 1000) 

Error in friedman.test.default(mf[[1L]], mf[[2L]], mf[[3L]]) : not an unreplicated complete block design

I do not quite understand why this happens. Does anyone have another way to calculate CI for the test statistic?

It's not clear why you need to calculate the CI for the Friedman statistic, particularly given the very small p-value, but here's a way to proceed if you do.
The problem is that the friedman.test() function, according to its R help page, requires "exactly one observation in [outcome] y for each combination of levels of groups and blocks," where the "group" is time in your case and "blocks" are your nr values. Your resampling leads to repeated nr values in the same group, violating that requirement.
You also don't seem to be resampling by block/nr, which would be more consistent with the original sampling: a set of individuals each followed over all time values. To do that, start by reshaping your data into wide format so that you select all observations for each nr value together. The tidyr nest() function can simplify that. After you've taken a bootstrap re-sample from the wide format, adjust the nr values so that there are no duplicates (to get around the warning from friedman.test()) and unnest() to long format for your tests.
