11-11-2013 12:38 AM
For those who would like to run a Kruskal-Wallis (KW) test on their non-parametric data, followed by a Dunn's post hoc test, Elliott has published a macro KW_MC on this site www.alanelliott.com/kw
Let's say you run the macro KW_MC (Kruskal-Wallis with Multiple Comaprison) on data containing 3 groups (A, B, C). This will produce an overall comparison across the 3 groups (a small table with title Kruskal-Wallis Test) and a Dunn's post hoc test in 3 paired comparison (A vs B, B vs C, C vs A, the table on the last page with the title Kruskal-Wallis Tied Ranks). This macro works well for data with just one group variable, which is specified by a single global macro variable "GROUP". My data are, however, more complex in that I have 4 grouping variables:
My data are in long-format and all the response variables are grouped into 2 column- one with the type (respType) and the other with the value (respVar).
I would like to run the KW analysis across all the subgroup combinations (exp_name x respType x trt_group x replicate) and for each of these combinations run a Dunn's post hoc test between any of the two groups (in trt_label). I've tweaked the PROC NPAR1WAY (see KW_MC.sas) and results of the overall comparison are output to the dataset 'kw_overall.' However, I got stuck when attempting to modify the codes following the the PROC NPAR1WAY. I didn't even find a dataset that contains the complete statistics of Duntrtn's post hoc (however, these are passed to the RTF file). Can anyone please advise on how to tweak the macro so it can take multiple grouping variables (in my case: exp_name x replicate x trt_group x respType )? Although this question may sound like a statistical one, it is actually more about macro writing skills.
My explanation for each file:
Thanks in advance!!
11-11-2013 09:08 AM
Some points to consider:
Kruskal-Wallis is set up for a one-way analysis of variance. Multiple levels of a single variable. If you have more than one independent variable, it isn't appropriate. If you have equal replication for all levels, a Friedman test can be applied for a two-way analysis of variance.
So long as you have equal replication in "exp_name x respType x trt_group x replicate" for all levels, you could treat it as a one-way analysis (like a means model in GLMMs). However, I don't see the reason for including respType--it seems to code for a response variable, and its inclusion opens up a multivariate approach (which, at least the ranks should overcome)--or replicate, which in the sample data has the same value(=1) for all observations. Create a dummy variable that has all levels of the four-way interaction (3x6x3x1 for the example data) and pass that to the macro. Now, unfortunately I don't remember if rank transformation is well-preserved as far as coming up with main effect and interaction estimates. I know NPAR1WAY doesn't support estimates as in the linear model procs.
I would really consider rank transforming the data prior to analysis, and using PROC GLIMMIX or something similar, to analyze this data.
08-31-2016 11:08 AM
I am attempting to run the Dunn Macro package of code right now. I am about half way through but have gotten snagged on a data step. It seems like there are more coming up as well.
data KW_MC_TMP5;set KW_MC_TMP5;
1295 keep n mean1-mean&groups;
WARNING: Apparent symbolic reference GROUPS not resolved.
ERROR: Missing numeric suffix on a numbered variable list (mean1-mean).
ERROR 22-322: Syntax error, expecting one of the following: a name, ;, _ALL_, _CHARACTER_,
ERROR 200-322: The symbol is not recognized and will be ignored.
Is there a way to resolve this? I am relatively new to SAS and trying to learn while using (not highly recommended) but any advice with this will be greatly appreciated.
The upcoming steps have similar synthax.
data KW_MC_TMP6;set KW_MC_TMP6;
keep n n1-n&groups;
data KW_MC_TMP7;set KW_MC_TMP7;
keep n gp1-gp&groups;