Hello,
I am novice in JSL. I try to do a Wilcoxon test for a range of columns. My first column is "ID" and second is "SEX" which I used as parameter.
So, I wrote the following code to do analysis and export results to a journal :
dt = Current Data Table();
column_names = dt << Get Column Names;
for(i=3,i<=length(column_names),i++,
ow = ow || "
Oneway(
Y( :Name(" || column_names || ") ),
X( :SEX ),
Wilcoxon Test( 1 ),
Box Plots( 0 ),
Mean Diamonds( 0 )
); "
);
eval(parse(ow)) << Journal();
But it doesn't work and I don't know what is wrong with code.
I also have another question : "Is it possible to export only P value to a journal ? I used SendToReport (dispatch ..... ) but there are still section titles in results. What I need is only my column name and P value. Is it possible ?"
Please help me.
Thanks in advance
Try this:
dt = Open("$SAMPLE_DATA/Big Class.jmp");
column_names = dt << Get Column Names(numeric,String);
jw = New Window("demo",<<journal);
for(i=1,i<=NItems(column_names),i++,
colName = column_names;
cmd = Expr(
ow = Oneway(
Y( cName ),
X( :SEX ),
Wilcoxon Test( 1 ),
Box Plots( 0 ),
Mean Diamonds( 0 );
);
owr = ow<<report;
owr << Outline Box(1) << Close;
pValues = owr[TableBox(3)];
jw << Append(ob = Outline Box(colName));
ob << Append( pValues );
ob << Append( owr );
ow << Close Window;
);
Substitute Into(cmd,Expr(cName),colName);
Eval(cmd);
);
or if you just want the column name and p-value ....
dt = Open("$SAMPLE_DATA/Big Class.jmp");
column_names = dt << Get Column Names(numeric,String);
results = New Table("Results", invisible,
New Column("Name", character),
New Column("P-Value", numeric),
Add Rows(NItems(column_names))
);
for(i=1,i<=NItems(column_names),i++,
colName = column_names;
cmd = Expr(
ow = dt << Oneway(
Y( cName ),
X( :SEX ),
Wilcoxon Test( 1 ),
Box Plots( 0 ),
Mean Diamonds( 0 );
);
owr = ow<<report;
matPValue= owr[NumberColBox(11)];
pValue = matPValue[1];
Column(results,1) = colName;
Column(results,2) = pValue;
ow << Close Window;
);
Substitute Into(cmd,Expr(cName),colName);
Eval(cmd);
);
results << journal;
Close(results);
-Dave
Try this:
dt = Open("$SAMPLE_DATA/Big Class.jmp");
column_names = dt << Get Column Names(numeric,String);
jw = New Window("demo",<<journal);
for(i=1,i<=NItems(column_names),i++,
colName = column_names;
cmd = Expr(
ow = Oneway(
Y( cName ),
X( :SEX ),
Wilcoxon Test( 1 ),
Box Plots( 0 ),
Mean Diamonds( 0 );
);
owr = ow<<report;
owr << Outline Box(1) << Close;
pValues = owr[TableBox(3)];
jw << Append(ob = Outline Box(colName));
ob << Append( pValues );
ob << Append( owr );
ow << Close Window;
);
Substitute Into(cmd,Expr(cName),colName);
Eval(cmd);
);
or if you just want the column name and p-value ....
dt = Open("$SAMPLE_DATA/Big Class.jmp");
column_names = dt << Get Column Names(numeric,String);
results = New Table("Results", invisible,
New Column("Name", character),
New Column("P-Value", numeric),
Add Rows(NItems(column_names))
);
for(i=1,i<=NItems(column_names),i++,
colName = column_names;
cmd = Expr(
ow = dt << Oneway(
Y( cName ),
X( :SEX ),
Wilcoxon Test( 1 ),
Box Plots( 0 ),
Mean Diamonds( 0 );
);
owr = ow<<report;
matPValue= owr[NumberColBox(11)];
pValue = matPValue[1];
Column(results,1) = colName;
Column(results,2) = pValue;
ow << Close Window;
);
Substitute Into(cmd,Expr(cName),colName);
Eval(cmd);
);
results << journal;
Close(results);
-Dave
Dear Dave,
Thanks a lot for your help. It really saved my time.
However, when I tried the second script, I got no answer so I changed the result table property to "visible" and I found out although it created right number of rows corresponding to number of columns I need to analyze, no data was injected in result table.
I appreciate if you give me a hint how to solve it.
Thanks in advance fo your valuable helps.
This is what the output should look like for the second script:
What version of JMP are you using? I've run it successfully on v9 and v10.
Also take a look at the log file to see if you get any error messages.
The p-values are extracted by referencing the appropriate display box in the tree structure of the report using the following line of code:
matPValue= owr[NumberColBox(11)];
The name of the display box - NumberColBox(11) - is identified by looking at the tree structure ... so you could try this to verify that the display box name is correct:
after the line:
owr = ow<<report;
add:
owr << show tree structure;
which will give output something like this:
-Dave
Dear Dave,
Thanks for your quick and detailed answer.
I work with JMP8 and it seems that the structure is a bit different. In my version "NumberColBox(7)" refers to p value.
I also appreciate for your tip about how to see the tree structure. It is a great help.
Good Luck