如何通过两列的 UniqueVals 组合进行选择和排除?所以我在这里被难住了。我试图输出一个经过筛选的 dt,该 dt 仅包含具有统计意义的数据,基于两列:Chart_ID 和 Recipe_ID。我可以让它在单列下工作,但无法弄清楚两列。
- 我正在使用 Oneway(y=mean、x=chamber、BY:Chart_ID、Recipe_ID)绘制原始数据并运行 All-pairs Tukey tTest。
- 然后获取合并的 pVal 数据表。
- 然后选择 pVal >0.05 的所有行并排除
- 然后按 Chart_ID 创建 UniqueVals 的汇总列表(这是所有具有显著 pVals 的 Chart_ID。)
- 然后选择源 dt 中的所有行,并匹配 UniqueVals
- 然后反转选择并排除
- --> 这使得源 dt 仅保留通过 Chart_ID 进行 tTest 显著的数据。
我不知道如何将 Recipe_ID 添加到汇总 UniqueVals 中。
有没有更好的方法来最终得到一个排除所有不重要的图表/食谱的源 dt?
//dtSPC --> my source data, raw SPC data. Need to exclude rows from Charts, Recipes with high pVals
/*plotting a basic Fit YbyX just to get pValues. Formatting and style done on final plot*/
ow1 = Oneway(
Y( :MEAN ),
X( :CHAMBER ),
By(:CHART_ID, :RECIPE),
//All pairs Tukey HSD test
All Pairs(
1,
Confidence Quantile( 0 ),
Difference Matrix( 0 ),
LSD Threshold Matrix( 0 ),
Connecting Letters Report( 0 ),
Ordered Differences Report( 1 )
),
);
/***********************************/
/***********************************/
// Create the combined data table, using xPath (return a list of the OutlineBoxes from the report that have the title Ordered Differences Report. Then, use the first of those to make the combined data table.)
outlines = (Report( ow1[1] ) << Top Parent) << XPath( "//OutlineBox[text()='Ordered Differences Report']" );
dt1 = outlines[1][Table Box( 1 )] << Make Combined Data Table;
dt1 = current data table();
dt1 << set name( "pValue PairWise by Channel Tukey");
dt1:CHART_ID << Data type( Numeric ) << Set Modeling Type( Nominal );
/***********************************/
/**********************************/
//Screen and show only the CHART_ID's w/ a Tukey pair pVal<0.05
//exclude all high pVal rows, leaving only low pVal Channels. Does not work in reverse.
dt1 << select where(:name("p-Value") > 0.05);
dt1 << exclude;
dt1 << clear select;
//create a list of remaining Unique CHART_ID's
summarize(dt1, uniqueVals=by(:CHART_ID));
//Convert to numeric
For( i = 1, i <= N Items(uniqueVals ), i++,
uniqueVals[i] = Num(uniqueVals[i] )
);
//extra, just to look at the data
//dtUnique = New Table( "uniqueVals less 0.05");
//dtUnique << New Column( "CHART_ID", Values(uniqueVals));
//select on SPC source data just the channels w/ low pVals
//need to choose SPC data table
dtSPC << clear select;
dtSPC << select where( contains( uniqueVals, :CHART_ID));
//invert and exclude, leaving only low pVal CHART_ID's
dtSPC << invert row selection << exclude;
dtSPC << clear select;数据混合和清理回复:如何通过两列的 UniqueVals 组合选择和排除?那行得通!如此简单的胜利。将连接的值发送到字符串。回复:如何通过两列的 UniqueVals 组合选择和排除?如果列中有重复的值,我之前的 Associative Array() 解决方案将无法正常工作(你可以很容易地修复它),所以我使用的是 for-loop 版本。
这会做你想要的吗?
Names Default To Here(1);
dtPopCorn = Open( "$SAMPLE_DATA/Popcorn.jmp" );
/*plotting a basic Fit YbyX just to get pValues. Formatting and style done on final plot*/
ow1 = Oneway(
Y( :yield ),
X( :batch),
By(:trial, :popcorn),
//All pairs Tukey HSD test
All Pairs(
1,
Confidence Quantile( 0 ),
Difference Matrix( 0 ),
LSD Threshold Matrix( 0 ),
Connecting Letters Report( 0 ),
Ordered Differences Report( 1 )
),
);
/***********************************/
/***********************************/
// Create the combined data table, using xPath (return a list of the OutlineBoxes from the report that have the title Ordered Differences Report. Then, use the first of those to make the combined data table.)
outlines = (Report( ow1[1] ) << Top Parent) << XPath( "//OutlineBox[text()='Ordered Differences Report']" );
dt1 = outlines[1][Table Box( 1 )] << Make Combined Data Table;
dt1 << set name( "pValue PairWise by Channel Tukey");
/***********************************/
/**********************************/
pVals = Loc(dt1:"p-Value"n << get as matrix <= 0.05);
comparisonStrings = {};
For(i = 1, i <= N Items(pVals), i++,
Insert Into(comparisonStrings, char(dt1:trial[pVals[i]]) || dt1:popcorn[pVals[i]]);
);
show(comparisonStrings);
dtPopCorn << clear select;
dtPopCorn << select where(contains(comparisonStrings, char(:trial)||:popcorn));只有 p 值低于 0.05 的组合是试验 = 2 和爆米花 = 美食。

回复:如何通过两列的 UniqueVals 组合选择和排除?@jthi
谢谢你的提示,但我对你的脚本有点困惑。 看起来它只是做了几次选择,但没有做任何事情来循环回到源 dt。
我可以从组合数据表中选择 pVal 就好了。 我遇到的麻烦是尝试通过组合数据表中的两列进行汇总,然后循环回到主要源数据并使用汇总进行选择。
我找到了一个样本集,看起来我们可以用来讨论这个问题。
我不知道如何使用两个 BY 列总结回源 dt
由(:试验,:油量),
dtPopCorn = Open( "$SAMPLE_DATA/Popcorn.jmp" );
/*plotting a basic Fit YbyX just to get pValues. Formatting and style done on final plot*/
ow1 = Oneway(
Y( :yield ),
X( :popcorn ),
By(:trial, :oil amt),
//All pairs Tukey HSD test
All Pairs(
1,
Confidence Quantile( 0 ),
Difference Matrix( 0 ),
LSD Threshold Matrix( 0 ),
Connecting Letters Report( 0 ),
Ordered Differences Report( 1 )
),
);
/***********************************/
/***********************************/
// Create the combined data table, using xPath (return a list of the OutlineBoxes from the report that have the title Ordered Differences Report. Then, use the first of those to make the combined data table.)
outlines = (Report( ow1[1] ) << Top Parent) << XPath( "//OutlineBox[text()='Ordered Differences Report']" );
dt1 = outlines[1][Table Box( 1 )] << Make Combined Data Table;
dt1 = current data table();
dt1 << set name( "pValue PairWise by Channel Tukey");
dt1:trial << Data type( Numeric ) << Set Modeling Type( Nominal );
/***********************************/
/**********************************/
//Screen and show only the trial's w/ a Tukey pair pVal<0.05
//exclude all high pVal rows, leaving only low pVal Channels. Does not work in reverse.
dt1 << select where(:name("p-Value") > 0.5); //I know...just setting 0.5 so that one row stands out.
dt1 << exclude;
dt1 << clear select;
//create a list of remaining Unique trial's
summarize(dt1, uniqueVals=by(:trial));
//Convert to numeric
For( i = 1, i <= N Items(uniqueVals ), i++,
uniqueVals[i] = Num(uniqueVals[i] )
);
//extra, just to look at the data
//dtUnique = New Table( "uniqueVals less 0.5");
//dtUnique << New Column( "trial", Values(uniqueVals));
//select on SPC source data just the channels w/ low pVals
//need to choose SPC data table
dtPopCorn << clear select;
dtPopCorn << select where( contains( uniqueVals, :trial));
//invert and exclude, leaving only low pVal trial's
dtPopCorn << invert row selection << exclude;
dtPopCorn << clear select;回复:如何通过两列的 UniqueVals 组合选择和排除?您可以将数字列转换为字符,然后连接两列以获取比较字符串列表。 然后使用该列表选择想要的行(或使用关联数组)。 没有示例数据集,所以这里有一个示例:
Names Default To Here(1);
dt = New Table("Untitled 22",
Add Rows(5),
Compress File When Saved(1),
New Column("CHART_ID",
Character,
"Nominal",
Set Values({"123", "1", "12", "0", "135"})
),
New Column("RECIPE",
Character,
"Nominal",
Set Values({"A", "A", "B", "B", "C"})
),
New Column("pval",
Numeric,
"Continuous",
Format("Best", 12),
Set Values([0.1, 0.001, 0.051, 0.002, 0.1])
)
);
pVals = Loc(dt:pval << get as matrix > 0.05); //get rows over 0.05
comparisonStrings = {};
For(i = 1, i <= N Items(pVals), i++,
Insert Into(comparisonStrings, char(dt:CHART_ID[pVals[i]]) || dt:RECIPE[pVals[i]]);
);
wait(1);
dt << Select Where(Contains(comparisonStrings, char(:CHART_ID)||:RECIPE));
wait(1);
dt << clear select;
wait(1);
aa = Associative Array(Eval List(dt:CHART_ID[pVals]), EvalList(dt:RECIPE[pVals]));
dt << Select Where(Contains(aa, :CHART_ID) & aa[:CHART_ID] == :RECIPE);使用 Scripting Index 更好地了解正在发生的事情(并在需要时进行调试)。
回复:如何通过两列的 UniqueVals 组合选择和排除?谢谢你的信息。 我阅读了 ASA 的声明,它主要是有道理的。 然而,我的情况(我假设许多其他人)正在处理成千上万的图表,我需要一种方法来快速筛选和修剪列表以查看最重要的。 这是一个屏幕截图作为示例。 我有 5000 张图表要筛选,需要一种好的方法来识别最重要的图表,以便花时间查看。 我得在某处划清界限。
我也查了 FDR,但我认为这不适用,因为我只使用了一个 X 特征。 只有一个 X 就不会发生 FDR。

关于选择和总结:
就是这样。 我不知道如何获得汇总然后转换为让我选择源数据。
以前,我选择单列 (Chart_ID) 然后转换回数字,因为 Summarize 输出字符。 从那里,我能够通过 UniqueVals 列表(即 Chart_ID)选择源 dt Chart_ID Col。
如何使用两个不同的数字和字符列来实现这一点?
回复:如何通过两列的 UniqueVals 组合选择和排除?嗨,alegner1!
也许我不明白,但是您可以尝试选择重要的 p 值,对新表进行子集化,然后通过 Chart_ID 和 Recipe_ID 进行汇总?
再说一次,也许我不明白,但你在做什么有点“黑客攻击”。至少,我建议您阅读 ASA 关于 p 值的声明,然后在 JMP 帮助下的统计索引中查找错误发现率。
祝你好运!