如何編寫for循環的腳本,以對數據表中的所有Y列執行單向方差分析我有一個大型數據表,其中包含10,000個不同的列名,以及少量的行,其中包含5個不同樣品組(包括一個標有“ HN30”的對照組)的重複樣品。我有一個腳本,如果我一次指定每個Y變量,將對對照組(HN30)進行單因素方差分析和Dunnett事後均值比較測試(即均值比較)。 但是,我不想輸入所有10,000個不同的列名稱,也不想被提示運行Dunnett測試或為每個列分析輸入控件名稱。有人可以幫我編寫一個for循環,一次一次遍歷所有列的命令。 一旦獲得輸出,我就知道如何使用Combines Tables命令合併所有輸出P值。下面是我對名為“ SPP1”和“ ABCC2”的兩個指定列的工作原理,其中控制組行標記為“ HN30”。只需要遍歷所有列即可。 非常感謝 !
Fit Group(
Oneway(
Y( :SPP1 ),
X( :Cell lline ),
With Control( 1, {"HN30"} ),
Comparison Circles( 1 ),
SendToReport(
Dispatch(
{"Means Comparisons",
"Comparisons with a control using Dunnett's Method",
"LSD Threshold Matrix"},
"p-Value",
NumberColBox,
{Set Format( "Fixed Dec", 15, 15 )}
)
)
),
Oneway(
Y( :ABCC2 ),
X( :Cell lline ),
With Control( 1, {"HN30"} ),
Comparison Circles( 1 ),
SendToReport(
Dispatch(
{"Means Comparisons",
"Comparisons with a control using Dunnett's Method",
"LSD Threshold Matrix"},
"p-Value",
NumberColBox,
{Set Format( "Fixed Dec", 15, 15 )}
)
)
),
<<{Arrange in Rows( 1 )}
);腳本編寫回复:我如何編寫一個for循環腳本,以便對數據表中的所有Y列執行單向方差分析這是一個循環的例子。 也許您可以適應您的需求。
您可以在腳本索引或腳本參考中找到所用命令的示例(如果需要)。
Names Default To Here( 1 );
cdt = Open( "$SAMPLE_DATA/Semiconductor Capability.jmp" );
all_ys = cdt << get column names( Continuous, String );
For( i = 1, i <= n items(all_ys), i++,
Eval( Parse( Eval Insert( "oneway( X( :SITE ), Y( :^all_ys[i]^ ) )" ) ) )
);
回复:如何編寫for循環的腳本,以便對數據表中的所有Y列執行單向方差分析謝謝喬治,
我將您的示例調整為適合自己的特定表,然後為每列運行所有單向方差分析,因此該部分可以正常工作。但是,我仍然不知道如何在Dunnett測試中遵循每個方差分析。不確定如何使用for循環來構造該子命令。這是到目前為止的內容,但是我無法顯示在底部的特定Dunnett測試在for循環中運行。有任何想法嗎?再次感謝
Names Default To Here( 1 );
cdt = Open( "F:/Stats/DTest.jmp" );
all_ys = cdt << get column names( Continuous, String );
For( i = 1, i <= n items(all_ys), i++,
Eval( Parse( Eval Insert( "oneway( X( :Cell lLine ), Y( :^all_ys[i]^ ) )" ) ) )
);
Fit Group(
Oneway(
Y( :SPP1 ),
X( :Cell lline ),
With Control( 1, {"HN30"} ),
Comparison Circles( 1 ),
SendToReport(
Dispatch(
{"Means Comparisons",
"Comparisons with a control using Dunnett's Method",
"LSD Threshold Matrix"},
"p-Value",
NumberColBox,
{Set Format( "Fixed Dec", 15, 15 )}
)
)
),
Oneway(
Y( :ABCC2 ),
X( :Cell lline ),
With Control( 1, {"HN30"} ),
Comparison Circles( 1 ),
SendToReport(
Dispatch(
{"Means Comparisons",
"Comparisons with a control using Dunnett's Method",
"LSD Threshold Matrix"},
"p-Value",
NumberColBox,
{Set Format( "Fixed Dec", 15, 15 )}
)
)
),
<<{Arrange in Rows( 1 )}
);回复:我如何編寫一個for循環腳本,以便對數據表中的所有Y列執行單向方差分析您可以嘗試以下方法:
Names Default To Here( 1 );
cdt = Open( "$SAMPLE_DATA/Semiconductor Capability.jmp" );
ow_expr = Expr(
Oneway(
Y( Column( all_ys[i] ) ),
X( :SITE ),
/* 3rd site is control */
With Control( 1, {3} ),
Comparison Circles( 1 ),
SendToReport(
Dispatch(
{"Means Comparisons", "Comparisons with a control using Dunnett's Method", "LSD Threshold Matrix"},
"p-Value",
NumberColBox,
{Set Format( "Fixed Dec", 15, 15 )}
)
)
)
);
all_ys = cdt << get column names( Continuous, String );
//For( i = 1, i <= n items(all_ys), i++,
For( i = 1, i <= 3, i++,
Eval( Substitute( ow_expr, Expr( i ), i ) );
// Eval( Substitute( Expr( oneway( X( :SITE ), Y( Column( all_ys[i] ) ) ) ), Expr( i ), i ) )
// Eval( Parse( Eval Insert( "oneway( X( :SITE ), Y( :^all_ys[i]^ ) )" ) ) )
);