如何编写数千个特征的 Wilcoxon 秩和检验脚本

各位专家大家好,我是 JMP 的用户。 我写这篇文章是为了学习如何编写脚本来计算数千个特征的 Wilcoxon 秩和测试结果。 分组和特征表(从feature_1到feature_n)如上图所示。 这是我要做的:
1) Wilcoson 秩和检验“治疗A与不治疗"对于 feature_1 到 feature_2000。 我知道我需要使用“fit Y by X”功能。 X应该是分组(治疗); Y 应该是对应于feature_1, 2....n 的值。
2)我明白如何做到这一点。 每个功能的代码有点像这样:
适合组(
Oneway( Y( :Feature_1 ), X( :治疗 ), Wilcoxon 测试( 1 ) ),
但是,我不知道如何编写脚本让它拾取只有“无治疗”和“治疗A”的列项目;以及如何让它循环运行以完成功能 1,然后完成功能 2,直到功能 2000。
我已尽力阅读脚本指南。 然而,我只能抓住基本概念,并不能真正解决它。 如果这里有人至少能伸出援手,我将非常感激。
太感谢了..
最好的,
温德米尔
回复:如何编写数千个特征的 Wilcoxon 秩和检验脚本是的...你是对的。 我不应该使用 $.
谢谢
我相信你和吉姆的解决方案现在都有效
回复:如何编写数千个特征的 Wilcoxon 秩和检验脚本最后,它有效...
这是一个很好的学习经历。
谢谢
温德米尔
回复:如何编写数千个特征的 Wilcoxon 秩和检验脚本认为您只需要在要打开的文件的文件名开头添加“C”(而不是“$C”)。
回复:如何编写数千个特征的 Wilcoxon 秩和检验脚本嗨吉姆,如果我尝试打开不在 SAMPLE_DATA 中但在 Windows 下某处的数据集,例如,像这样“C:\Users\yuanyli4\Desktop\JMP TEST\Sheet1.jmp”
我应该这样写吗?
dt= 打开("$C:\Users\yuanyli4\Desktop\JMP TEST\Sheet1.jmp");
谢谢
回复:如何编写数千个特征的 Wilcoxon 秩和检验脚本dt = Open( "$C:\Users\yuanyli4\Desktop\JMP TEST\Sheet1.jmp" );
colList = dt << Get Column Names( Continuous );
dt2 = dt << Stack(
columns( colList ),
source Label Column( "Feature" ),
Stacked Data Column( "Data" ),
Output Table( (dt << getName) || "Stacked" )
);
Close( dt, NoSave );
ow = dt2 << Oneway(
Y( :Data ),
X( :Treatment ),
wilcoxon Test( 1 ),
By( :Feature )
);
firstOwRep = Report( ow[1] );
dt3 = firstOwRep[Table Box( 3 )] << makeCombinedDataTable;
dt3 << setName( "One Way Chisquare Results By Feature" );
这是我根据最新建议写的东西。
它仍然无法正常工作... 
当我尝试运行它时。 完全没有反应...
回复:如何编写数千个特征的 Wilcoxon 秩和检验脚本这是一个做你想做的事的例子。我正在使用一个包含很多连续变量的示例数据表。我将连续列之一的名称更改为“Feature_1”,以模仿您所定位的列的名称。然后,我从 colList 中删除“Feature_1”列之前出现的所有连续列,然后对所有剩余列运行分析。
Names Default To Here( 1 );
/* Open a sample data table */
dt = Open( "$SAMPLE_DATA\semiconductor capability.jmp" );
// For illustration, change the name of one of the columns to "Feature_1"
Column( dt, 10 ) << set name( "Feature_1" );
/* Obtain a list of numeric/continuous column names */
colList = dt << Get Column Names( Continuous );
// Remove from the list of columns, all columns before the column called
// "Feature_1"
If( Contains( colList, Parse( "Feature_1" ) ) > 1,
colList = Remove( colList, 1, Contains( colList, Parse( "Feature_1" ) ) - 1 )
);
// Run the analysis
Fit Group(
Oneway( Y( Eval( colList ) ), X( :Wafer ), Wilcoxon Test( 1 ) ),
// If you want all of the outputs in a single row and you don't
// know how many there will be, a simple way to handle this is
// to just specify a large number
<<{Arrange in Rows( 200 )}
);
请花时间阅读脚本指南,了解脚本的全部内容
帮助==>书籍==>脚本指南
回复:如何编写数千个特征的 Wilcoxon 秩和检验脚本对不起。 它仍然不起作用。
我想知道任何人都可以帮助解决具体案例。 很抱歉,我不知道如何编写从名为Feature_1的列开始到结束的循环。 我真的希望谁能解释一下如何编写脚本。
谢谢
回复:如何编写数千个特征的 Wilcoxon 秩和检验脚本另一个需要考虑的选项是 JMP 响应筛选功能。 它不进行秩和检验,而是进行 t 检验或稳健检验(以减轻异常值)。 它运行速度快,提供 p 值表、显着性与效果大小的图表,最重要的是有一个“拟合选定”选项,这样您就可以轻松地拟合您最感兴趣的那些特征的 Y 乘 X,然后您可以对 2000 个特征的子集运行 Wilcoxon 测试。
https://www.jmp.com/support/help/14/response-screening.shtml
回复:如何编写数千个特征的 Wilcoxon 秩和检验脚本吉姆已经给了你一些很大的帮助和指导。
如果我理解正确的话,您可能有超过 2,000 个特征,因此避免循环遍历它们可能会更有效。 此外,查看 2,000 份报告并不好,因此您可能需要以某种方式总结结果。
在这种情况下,您确实可以避免循环,因此您可能想了解下面的代码如何工作,以帮助您进一步使用 JSL。 一般来说,堆叠数据并使用“By”变量是一个需要注意的良好编码模式。 当然,在示例中只有两个“特征”(高度和重量)。
// Open a sample data table
dt = Open( "$SAMPLE_DATA\big class.jmp" );
// Obtain a list of column names containing the 'features'
colList = dt << Get Column Names( Continuous );
// Stack the data
dt2 = dt << Stack(
columns( colList ),
Source Label Column( "Feature" ),
Stacked Data Column( "Data" ),
Output Table( (dt << getName)||" Stacked" )
);
Close(dt, NoSave);
// Do the Wilcoxon tests all at the same time (this will be a list, due to the use of the 'By' variable)
ow = dt2 << Oneway( Y( :Data ), X( :sex ), Wilcoxon Test( 1 ), By(:Feature) );
// Get a link to the first report
firstOwRep = Report(ow[1]);
// Get the one way ChiSq results from ALL reports (features) into a single table
dt3 = firstOwRep[TableBox(3)] << makeCombinedDataTable;
dt3 << setName("One Way ChiSquare Results By Feature");
当然,当进行数千次统计测试时,您需要考虑误报率将不可避免地很高。
回复:如何编写数千个特征的 Wilcoxon 秩和检验脚本谢谢您,您说得对,我没有接受过脚本写作培训和经验。
我会再试一次,也需要阅读。 如果我不明白的话,我希望你不要介意我在这里发布任何内容......
再次感谢您的耐心等待。
最好的,
温德米尔
回复:如何编写数千个特征的 Wilcoxon 秩和检验脚本下面是一个带注释的脚本,应该可以满足您的需求。
/* Open a sample data table */
dt = Open( "$SAMPLE_DATA\big class.jmp" );
/* Obtain a list of numeric/continuous column names */
colList = dt << Get Column Names( Continuous );
// If you run a Oneway analysis, and specify to Arrange in Rows
// and then save the script, it generates
/*
Fit Group(
Oneway( Y( :height ), X( :sex ) ),
Oneway( Y( :weight ), X( :sex ) ),
<<{Arrange in Rows( 200 )}
)
*/
// A little modification to include all of the columns that
// were extracted using the << Get Columns Names message, and
// the script below will give you what you want
Fit Group(
Oneway( Y( Eval( colList ) ), X( :sex ) ),
// If you want all of the outputs in a single row and you don't
// know how many there will be, a simple way to handle this is
// to just specify a large number
<<{Arrange in Rows( 200 )}
);
上面脚本中的所有函数和消息均在脚本索引中通过示例进行了记录
帮助==>脚本索引
JSL 结构和方法记录在脚本指南中
帮助==>书籍==>脚本指南
然而,您目前的编程知识和经验似乎有限。我强烈建议您从众多有关编程简介的书籍中挑选一本。虽然您找不到有关“JMP 脚本语言编程简介”的书,但真正需要的是学习编程概念。一旦理解了这一点,那么在编程世界中的语言之间切换就变成了学习新语言的新语法的简单问题。
回复:如何编写数千个特征的 Wilcoxon 秩和检验脚本
/* Open a sample data table */
dt = Open( "$Sheet1.jmp" );
/* Obtain a list of numeric/continuous column names as strings */
colList = dt << Feature_1( Continuous, String );
For( i = 2, i <= N Items( colList ), i++, );
Oneway(
Y( :colList ),
X( :Treatment ),
Wilcoxon Test( 1 )
);
<<{Arrange in Rows( 1 )};
这是我使用的脚本。
很遗憾,
它根本不起作用..
没有回应。
有谁知道为什么?
谢谢
回复:如何编写数千个特征的 Wilcoxon 秩和检验脚本嗨特克斯尼尔森,
感谢您的帮助。 只是想确保我以正确的方式理解以下内容。
1.
<SPAN class="token comment">/* Obtain a list of numeric/continuous column names as strings */</SPAN>
colList <SPAN class="token operator">=</SPAN> dt <SPAN class="token operator"><</SPAN><SPAN class="token operator"><</SPAN><SPAN class="token messages"> Get Column Names</SPAN><SPAN class="token punctuation">(</SPAN> Continuous<SPAN class="token punctuation">,</SPAN> String <SPAN class="token punctuation">)</SPAN><SPAN class="token punctuation">;</SPAN>
对于我的表,我应该将其写为
colList <SPAN class="token operator">=</SPAN> dt <SPAN class="token operator"><</SPAN><SPAN class="token operator"><</SPAN><SPAN class="token messages"> "Feature_1"</SPAN><SPAN class="token punctuation">(</SPAN> Continuous<SPAN class="token punctuation">,</SPAN> String <SPAN class="token punctuation">); <BR /></SPAN>
这是对的吗?
2.
<SPAN class="token function">For</SPAN><SPAN class="token punctuation">(</SPAN> i <SPAN class="token operator">=</SPAN> <SPAN class="token number">2</SPAN><SPAN class="token punctuation">,</SPAN> i <SPAN class="token operator"><=</SPAN> <SPAN class="token function">Nitems</SPAN><SPAN class="token punctuation">(</SPAN> colList <SPAN class="token punctuation">)</SPAN><SPAN class="token punctuation">,</SPAN> i<SPAN class="token operator">++</SPAN><SPAN class="token punctuation">,</SPAN>
就我而言,它应该写成
<SPAN class="token function">For</SPAN><SPAN class="token punctuation">(</SPAN> i <SPAN class="token operator">=</SPAN> <SPAN class="token number">0</SPAN><SPAN class="token punctuation">,</SPAN> i <SPAN class="token operator"><=</SPAN> feature_2000<SPAN class="token punctuation">(</SPAN> colList <SPAN class="token punctuation">)</SPAN><SPAN class="token punctuation">,</SPAN> i<SPAN class="token operator">++</SPAN><SPAN class="token punctuation">,)</SPAN>
那是对的吗?
所以,我真的不明白 i=0、i=1、i=2 是什么意思? 您能解释一下吗?
“Nitems”应更改为最后一列的列名称 (feature_2000)。 我的理解正确吗?
另外,我们需要一个“)”来停止这个循环吗? 下面显示的模板没有“)”。
谢谢。
明天我会尝试这个脚本并向您提供反馈。
温德米尔
回复:如何编写数千个特征的 Wilcoxon 秩和检验脚本跨列循环并运行其中一个平台是讨论论坛中最常见的项目之一。搜索“循环”会出现多个选择。下面是一个循环示例,取自跨列循环和运行图形生成器平台的示例。单向平台的循环将非常相似。
/* Open a sample data table */
dt = Open( "$SAMPLE_DATA\Fitness.jmp" );
/* Obtain a list of numeric/continuous column names as strings */
colList = dt << Get Column Names( Continuous, String );
/* Loop through the list to generate the desired Graph Builder
and save the report as a JPEG file */
For( i = 2, i <= Nitems( colList ), i++,
gb = dt << Graph Builder(
Size( 534, 454 ),
Show Control Panel( 0 ),
Variables(
X( :Age ),
Y( Column( dt, colList[i] ) ),
Color( :Age )
),
Elements(
Points(
X,
Y,
Legend( 3 ),
Summary Statistic( "Mean" ),
Error Bars( "Confidence Interval" )
)
),
SendToReport(
Dispatch(
{},
"Graph Builder",
FrameBox,
{Marker Size( 5 )}
)
),
Invisible
);
gb << Save Picture( "E:\Trash\Graph Builder_" || colList[i] ||".jpg", JPEG );
);
/* Close table and all invisible reports */
Close( dt, No Save );回复:如何编写数千个特征的 Wilcoxon 秩和检验脚本你好,
感谢您提供选择群组信息的解决方案。
但是如何对feature_1、feature_2000作为循环进行测试呢? 您能否也提供一个解决方案?
谢谢
温德米尔
回复:如何编写数千个特征的 Wilcoxon 秩和检验脚本我可以快速看到的两个解决方案是将所有没有“无处理”或“处理 A”的行的行状态设置为“隐藏并排除”,然后运行 Fit Y by X 分析
names default to here(1);
dt=current data table();
dt << select where(:treatment !="No Treatment" & :treatment !="Treatment A");
<BR />dt << Hide and Exclude;
dt << Fit Group(
Oneway(………………………..));
或者,将数据子集到仅包含“无处理”和“处理 A”行的新表中,然后进行分析
names default to here(1);
dt=current data table();
dt << select where(:treatment =="No Treatment" | :treatment !=="Treatment A");
dt2=dt<<SUBSET></SUBSET>