I created a survey to find out if people spent more time in their gardens in 2020 when compared to 2019. I did a paired sample Wilcoxon test to compare the two and found a significant difference but now I'm unsure how best to present the data. I used ggplot in r to create this graph but I don't think it is the best way to show how I compared the data as a whole.

enter image description here

Here is an example of the raw data

2019 2020
Once a week A few times per week
Once a month Once a week
Never Never
A few times per week Everyday
Everyday Once a month

Any advice on what may be a better way to show this data would be very helpful and appreciated, thank you!

  • $\begingroup$ Can you paste in a small example dataset for people to work with? Note that there are several tests that can be called "Wilcoxon"; can you clarify what test you ran? $\endgroup$ Mar 11 '21 at 14:46
  • $\begingroup$ Just added these in! It was a paired sample Wilcoxon test $\endgroup$
    – Elisabeth
    Mar 11 '21 at 17:27
  • $\begingroup$ @Elisabeth Were the same people surveyed in both 2019 and 2020? $\endgroup$ Mar 11 '21 at 22:10
  • $\begingroup$ @DianaPetitti Yes they were $\endgroup$
    – Elisabeth
    Mar 11 '21 at 22:25

The primary thing to bear in mind is that the Wilcoxon signed rank test (i.e., the paired test) compares two values from within the same respondent. Typical plots don't take that into account and so there is a mismatch between the test and the plot. That isn't necessarily bad, so long as you and any other viewers hold that clearly in mind while viewing the plot, but in practice, many people won't. (For further discussion in the context of a paired $t$-test, see my answer to: Is using error bars for means in a within-subjects study wrong?) For a discussion of plots for the Wilcoxon signed rank test that do take the within-respondent nature into account, see: How to best visualize one-sample test?

Another way to present your data would be to provide a measure of the magnitude of the effect. Because to some extent the Wilcoxon signed rank test is checking the proportion of after values that are greater than before, you could give those proportions (for more detail, see my answer to: Effect size to Wilcoxon signed rank test?

If you want a figure to display those, rather than a list of numbers buried in the text, you could use a stacked bar chart or a dot plot. Below I use base R to generate some fake data, compute the effect size, and make a plot from that.

##### generate data
set.seed(3885)          # this makes the example exactly reproducible
before    = runif(140)  # data from uniform distribution
                        # after is before plus a samll random bump, typically up: 
after     = before + rnorm(140, mean=.05, sd=.1)
before    = findInterval(before, vec=c(-Inf, .05, .10, .25, .50, .70, .85, Inf))
after     = findInterval(after,  vec=c(-Inf, .05, .10, .25, .50, .70, .85, Inf))

##### descriptive stats & test
t(table(stack(list(before=before, after=after))))
#         values
# ind       1  2  3  4  5  6  7
#   before 10  6 25 39 25 18 17
#   after   4  7 21 41 26 14 27 
wilcox.test(before, after, paired=TRUE)
#         Wilcoxon signed rank test with continuity correction
# V = 360, p-value = 4.015e-06

##### effect size
change      = sign(after-before)
proportions = round(prop.table(table(change)), digits=2);  proportions
#    -1    0    1 
#  0.09 0.56 0.35 

##### plots
  layout(matrix(c(1,1,1,2), nrow=1))
  dotchart(proportions, pch=16, labels=c("less", "same", "more"),
           col=c("darkblue", "orange", "green"), pt.cex=2)
  barplot(as.matrix(proportions), beside=FALSE, 
          col=c("darkblue", "orange", "green"))

dot plot of proportions with stacked bar chart

Admittedly, with only three points, pairing the dot plot with the stacked bar chart is overkill, but I do like this pairing when there are more values.


This display focuses on change from 2019 to 2020. I guessed numbers from your graph and scaled to % in each year.

enter image description here

The graph needs, or benefits from, a supporting narrative. The arrows show change from 2019 to 2020, so an arrow pointing right shows increased in 2020 and an arrow pointing left shows decreased. The percent visiting at least 5 times a week went up, the percent visiting less frequently correspondingly went down, and the small fraction reporting never was about the same.

  • $\begingroup$ This is an interesting contribution, I like it. But I still have a preference for something that captures the within-respondent nature of the data / test. $\endgroup$ Mar 12 '21 at 19:48
  • $\begingroup$ Thanks, @gung. No disagreement from me. We don't have that data. I would like to see the data in that form. I would show a transition matrix as a bar chart. $\endgroup$
    – Nick Cox
    Mar 12 '21 at 19:53
  • $\begingroup$ Can you generate my simulated dataset from my R code & import it into Stata? d = data.frame(before=before, after=after); write.table(file=file.choose(), header=TRUE, row.names=FALSE, sep="\t") should work. That uses a tab deliminter, for commas, use: sep=",". $\endgroup$ Mar 12 '21 at 19:55
  • $\begingroup$ Oops, write.table(d, file=file.choose(), header=TRUE, row.names=FALSE, sep="\t") $\endgroup$ Mar 12 '21 at 20:05
  • $\begingroup$ I am holding out in the hope of real data here. BTW, I count different numbers in 2019 and 2020, which my graph ignores. Naturally, I can't correct for those who replied in one year and not other as I don't know who they are. Even more important for the OP's goals, the paired calculation should be ignoring them. $\endgroup$
    – Nick Cox
    Mar 13 '21 at 10:04

Not the answer you're looking for? Browse other questions tagged or ask your own question.