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?

I think the solution presented by @EdM is the correct approach to apply bootstrap for Friedman's test.
You may be interested in Kendall's W which is used as an effect size statistic for Friedman's test, and is a standardized version of the chi-square statistic from that test.
In R, one implementation is in the DescTools package (KendallW()). And I have a version which implements the confidence interval by bootstrap in the rcompanion package (kendallW()).
For each of these, the input is passed to the function as a table, e.g. by
 XT = xtabs(dash ~ time | nr, data = data_t)

If you conduct the bootstrap yourself, you might want to work with data in this table format.  The native friedman.test() function can also handle data in this format, so it should be easy to pass the bootstrap data to this function (without converting it back to long format).
