Hi Neil - this looks as if it'll need some scripting, I'm afraid. I've just had a go at it myself, and come up with the one below, which should produce the same Kruskal-Wallis P values as the Fit Y by X platform, for any nominal factor X and any number of Y variables. I've tried it out on the Big Class.JMP sample data set, using either Age or Sex as the X factor, and Height and/or Weight as the Y variable(s), and it seems to work, though I've no doubt it could be tidied up a lot. This program doesn't adjust the P values from the pairwise comparisons for multiple testing: the best I can suggest there would be to use the Bonferroni correction on them.
// Start of program;
DataFile = PickFile("Select Raw Data Table for Kruskal-Wallis Test:",, {"JMP Files|JMP"});
dt = open( DataFile );
dt << minimize window;
VarList = ColumnDialog(Title("Assign Roles:"),
Xfac = ColList("Factor ID", Min Col(1), Max Col(1)),
Yvar = ColList("Response(s)", Min Col(1), DataType(Numeric)),
);
Column(dt, Char(VarList["Xfac"][1])) << data type("Character");
Column(dt, Char(VarList["Xfac"][1])) << set modeling type("Nominal");
xCol = Column(dt, VarList["Xfac"]);
Response_List = VarList["Yvar"];
yCols = {};
for(i=1, i<=nItems(VarList["Yvar"]), i++,
insert into(yCols, Column(dt, Response_List[i]))
);
summarize(xLev=by(xCol)); // We'll need a list of the factor levels later, so create it now;
dt << select all rows;
dts = dt << subset(visible);
dto = Oneway(
Y( eval list( yCols ) ), X( eval list( xCol ) ),
Wilcoxon Test( 1 ), Box Plots( 0 ), Mean Diamonds( 0 ), invisible
);
dtoreport = dto << report;
// DTOREPORT will only be a list if there are at least two response variables;
if(islist(dtoreport),
chisqd = dtoreport[1][NumberColBox(5)] << MakeCombinedDataTable,
chisqd = dtoreport[NumberColBox(5)] << MakeCombinedDataTable
);
dtoreport << close window;
chisqd << add multiple columns("With", 1, Before First, Character);
chisqd << add multiple columns("Compare", 1, Before First, Character);
for(i=1, i<=nrow(chisqd), i++,
column(chisqd, "Compare")[i] = "All"; column(chisqd, "With")[i] = "All"
);
/*
We'll get a different set of summary statistics depending on whether xLev has more
than two levels or not, because if xLev > 2 then it's a chi-squared test, whereas
if there are only two levels the 2-sample test returns a Z statistic.
*/
if(nItems(xLev) > 2,
chisqd << delete columns({"ChiSquare", "DF"});
column(chisqd, "Prob>ChiSq") << set name("P Value");
,
chisqd << delete columns({"s", "Z"});
column(chisqd, "Prob>|Z|") << set name("P Value");
);
chisqd << select all rows;
Significances = chisqd << subset(visible);
close(chisqd, nosave);
Significances << set name("Significances");
column(Significances, "P Value") << format("Fixed Dec", 20, 4);
close(dts, nosave);
/*
Now run every pairwise comparison of all the levels of Xfac,
and append each of them in turn to Significances;
*/
if(nItems(xLev) > 2,
xName = Column(dt, VarList["Xfac"]) << get name;
for(k=1, k<=nItems(xLev)-1, k++,
for(l=k+1, l<=nItems(xLev), l++,
dt << select all rows;
TextToParse = "dt << select where((:" || xName || "==\!"" || xLev[k]
|| "\!")|(:" || xName || "==\!"" || xLev[l] || "\!"));";
// show(TextToParse);
eval(parse(TextToParse));
dts = dt << subset(invisible);
dts << set name("DTS");
xCol = Column(dts, VarList["Xfac"]);
Response_List = VarList["Yvar"];
yCols = {};
for(i=1, i<=nItems(VarList["Yvar"]), i++,
insert into(yCols, Column(dt, Response_List[i]))
);
dto = dts << Oneway(
Y( eval list( yCols ) ), X( eval( xCol ) ),
Wilcoxon Test( 1 ), Box Plots( 0 ), Mean Diamonds( 0 ), invisible
);
dtoreport = dto << report;
// DTOREPORT will only be a list if there are at least two response variables;
if(islist(dtoreport),
chisqd = dtoreport[1][NumberColBox(5)] << MakeCombinedDataTable,
chisqd = dtoreport[NumberColBox(5)] << MakeCombinedDataTable
);
chisqdi = chisqd << subset(invisible);
close(chisqd, nosave);
chisqdi << delete columns({"s", "Z"});
column(chisqdi, "Prob>|Z|") << set name("P Value");
column(chisqdi, "P Value") << format("Fixed Dec", 20, 4);
close(dts, nosave);
chisqdi << add multiple columns("With", 1, Before First, Character);
chisqdi << add multiple columns("Compare", 1, Before First, Character);
for(i=1, i<=nrow(chisqdi), i++,
column(chisqdi, "Compare")[i] = xLev[k]; column(chisqdi, "With")[i] = xLev[l]
);
Significances << Concatenate( chisqdi, Append to First Table );
close(chisqdi, nosave);
)
)
);
// Add a column of significance codes for P <= 0.05 = "*", P <= 0.01 = "**", P <= 0.001="***";
Significances << new column("Sig", Character(10));
for(i=1, i<=nrow(Significances), i++,
column(Significances, "Sig")[i] = if(column(Significances, "P Value")[i] <= 0.001, "***",
if(column(Significances, "P Value")[i] <= 0.01, "**",
if(column(Significances, "P Value")[i] <= 0.05, "*", "")
)
)
);
close(dt, nosave);
// End of program;
edit (Save) required to reset formatting
Message was edited by: ForumAdmin@sas