如何編寫數千個特徵的 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>