BookmarkSubscribeRSS Feed
katiexyz
Calcite | Level 5

Hi,

I have skewed data on which I want to perform multiple comparisons.

I accidentally performed parametric test which had the following code:

proc glm data=work PLOTS=(DIAGNOSTICS RESIDUALS);

class type;

model results=type;

estimate " " type 3 -1 -1 -1/e;

estimate " " type  -1 3 -1 -1/e;

estimate " " type -1 -1 3 -1/e;

estimate " " type  -1 -1 -1 3/e;

estimate " " type 2 0 -1 -1/e;

estimate " " type  0 0 -1 1/e;

estimate " " type -1 1 0 0/e;

run;

quit;

I now want to make the non-parametric version of that.... I don't know what to do Smiley Sad

So far I have:

PROC NPAR1WAY data=work wilcoxon;

Class TYPE;

Var results;

Run;

Which is fine, but then to make multiple comparisons I don't know what to do. 

Proc Multtest has been reccomended to me but I don't follow the syntax on the SAS site, and it all seems to give t-test results which seem imappropriate.  I am supposed to use the option "HOCHBERG" I believe.

Does anyone know how to help me?

Thanks Smiley Happy

5 REPLIES 5
PGStats
Opal | Level 21

Here is one way of doing all the tests and corrections (assuming variable type is numeric with values=1,2,3,4) :

data tests;
input testId $ type grp;
datalines;
test3111 1 1
test3111 2 2
test3111 3 2
test3111 4 2
test1311 1 2
test1311 2 1
test1311 3 2
test1311 4 2
test1131 1 2
test1131 2 2
test1131 3 1
test1131 4 2
test1113 1 2
test1113 2 2
test1113 3 2
test1113 4 1
test2011 1 2
test2011 3 1
test2011 4 1
test0011 3 1
test0011 4 2
test1100 1 1
test1100 2 2
;

proc sql;
create table workGrp as
select T.testId, T.grp, W.results
from work as W inner join tests as T
     on W.type=T.type
order by testId, grp;
quit;

proc npar1way data=workGrp wilcoxon;
by testId;
class grp;
var results;
ods output WilcoxonTest=Wtests;
run;

proc multtest HOCHBERG out=adjustedWtests
inpvalues(nValue1)=Wtests(where=(name1="P2_WIL"));
run;

proc print data=adjustedWtests; run;

PG

PG
Ksharp
Super User

PG,

There is no need to use proc npar1way since OP want  multiple comparisons , not two comparison.

proc glm is also a candidate .

Ksharp

katiexyz
Calcite | Level 5

I have no idea what either of you are talking about.
PG Stats: Why would I use proc sql? I don't know what any of that code means.

Ksharp: It isn't a linear model, I have non normal data so how can I use proc glm? Deffo proc par1way.

SteveDenham
Jade | Level 19

Here is another approach.  Use PROC MIXED to analyze the ranks, rather than the raw results.  Something like:

proc rank data=work out=rankeddata;

var results;

ranks rank_result;

run;

/* Change to PROC MIXED to get LSMESTIMATEs, which can be adjusted for multiple comparisons, and to accommodate the comparisons which are not just one group to another.  Multiple comparisons are the stepdown Bonferroni (Holm) adjustment */

proc mixed data=rankeddata ;

class type;

model rank_result=type;

lsmestimate  type 'Type 1 vs mean of remaining' 3 -1 -1 -1,

lsmestimate  type 'Type 2 vs mean of remaining' -1 3 -1 -1,

lsmestimate  type 'Type 3 vs mean of remaining' -1 -1 3 -1,

lsmestimate  type 'Type 4 vs mean of remaining' -1 -1 -1 3,

lsmestimate  type 'Type 1 vs mean of types 3 and 4' 2 0 -1 -1,

lsmestimate  type 'Type 3 vs type 4' 0 0 -1 1,

lsmestimate  type 'Type 1 vs type 2' -1 1 0 0/adjust=bon stepdown;

ods output lsmestimates=lsmestimates;

run;

/* If you want the Hochberg adjustment, then add the following.  See Example  61.5 Inputting Raw p-Values in the MULTTEST Procedure documentation.  In particular, read the last paragraph in this example, describing some general assumptions regarding the methods of adjustment */

/* First, pare down the lsmestimates dataset to just the labels and the p values */

data lsmestimates_for_multtest;

set lsmestimates;

raw_p=probt;

keep label raw_p;

run;

/*Now run the adjustments.  This will give adjustments using the stepdown Bonferroni (Holm, same as in PROC MIXED, hopefully), Hochberg and false discovery rate methods*/

proc multtest inpvalues=lsmestimates_for_multtest holm hoc fdr;

run;

Good luck.

Steve Denham

Message was edited by: Steve Denham

PGStats
Opal | Level 21

In my code above, many versions of your data are created, one for each of your estimate statements. In each version, the data is divided in two groups. Then npar1way is called to do all the Wilcoxon tests and multtest is called to correct the p-values for multiple testing.

PG

PG

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 2896 views
  • 0 likes
  • 4 in conversation