How do you perform Wilcoxon matched-pair sign-rank test in Stata using a grouping variable? [closed]

I'm performing a diagnostic method comparison study in which I have 2 groups; one assessed using the experimental method, and one assessed using the standard method. These groups are matched, with 3 standard per experiment.

Continuos variables measured are not normally distributed, and data is matched, thus I'm opting for the Wilcoxon matched-pair signed-rank test to compare variables between the groups.

Now, in Stata every command for comparison of groups (ttest, ranksum...) allows the by(group) option, but not -signrank- !

For example: ranksum age, by(cohort)

if I want to compare the age distribution between the groups (defined by var cohort). But -ranksum- is for unmatched data!

Thus, my question is how to, similarly to ranksum, perform -signrank- with a by(groupvar) option? -signrank- doesn't allow this by default.

Is there a user-written command for this?

I've seen the -reshape- command being used, but I'm not used to that and I don't really know how to use it.

closed as off-topic by Peter Flom♦Feb 11 at 18:59

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question appears to be off-topic because EITHER it is not about statistics, machine learning, data analysis, data mining, or data visualization, OR it focuses on programming, debugging, or performing routine operations within a statistical computing platform. If the latter, you could try the support links we maintain." – Peter Flom
If this question can be reworded to fit the rules in the help center, please edit the question.

But I would encourage you to think of this as an estimation problem rather than a hypothesis testing problem. I find it natural to use $$U$$-statistics based on all possible relevant pairs of measurements, to estimate the mean absolute discrepency between raters. You can use the bootstrap to get confidence intervals for same. Details are in Chapter 16 of BBR.
signrank allows a bysort option:
webuse fuel, clear