如何编写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]^ ) )" ) ) )
);