在列分位数计算中排除行你好,
我试图获取 Col Quantile( :height, 0.5, :class) 但看起来计算仍会考虑排除的行。
有没有办法拒绝排除的行进入 Col Quantile 计算?
谢谢,
绿
脚本回复:排除 Col 分位数计算中的行您可以在 Col Quantile() 函数中检查被排除的行。下面是一个例子
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << New Column( "Col Quantile Height by Age",
numeric,
continuous,
formula( Col Quantile(If(excluded(rowstate(Row())),., :height), 0.5, :age ) )
);
每当数据表中的行的排除行状态发生变化时,公式将计算新值
回复:在列分位数计算中排除行我尝试使用以下代码创建一个循环来收集许多参数的第 50 个百分位数,但“test_list”中的两个元素是相同的(它们都是权重的 50%)。但是,如果我手动运行这些线路,它就会起作用。我可以不在 for 循环中使用 Col Quantile() 函数吗?
名称默认为此处( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
绘图参数={
高度,
重量};
测试列表={};
对于(plotcnt=1,plotcnt<=nitems(plot_param),plotcnt++,
pct_50=列分位数( If(排除(rowstate(Row())),., 列(plot_param[plotcnt])), 0.5);
test_list[plotcnt]=pct_50;
);
回复:在列分位数计算中排除行
我尝试使用以下代码创建一个循环来收集许多参数的第 50 个百分位数,但“test_list”中的两个元素是相同的(它们都是权重的 50%)。但是,如果我手动运行这些线路,它就会起作用。我可以不在 for 循环中使用 Col Quantile() 函数吗?
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
plot_param={
height,
weight};
test_list={};
for(plotcnt=1, plotcnt<=nitems(plot_param), plotcnt++,
pct_50=Col Quantile( If(excluded(rowstate(Row())),., column(plot_param[plotcnt])), 0.5);
test_list[plotcnt]=pct_50;
); 回复:排除 Col 分位数计算中的行Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
plot_param={
height,
weight};
test_list={};
for(plotcnt=1, plotcnt<=nitems(plot_param), plotcnt++,
Eval (Substitute (Expr(pct_50=Col Quantile( If(excluded(rowstate(Row())),., _col_), 0.5)), Expr(_col_), column(plot_param[plotcnt])));
test_list[plotcnt]=pct_50;
);
回复:排除 Col 分位数计算中的行由于打字错误,我刚刚注意到 Eval (substitute()) 就足够了,即使你用 1 替换 1:
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
plot_param = {height, weight};
test_list = {};
For( plotcnt = 1, plotcnt <= N Items( plot_param ), plotcnt++,
pct_50 = Eval( Substitute( Expr( Col Quantile( If( Excluded( Row State( Row() ) ), ., Column( plot_param[plotcnt] ) ), 0.5 ) ), 1, 1 ) );
test_list[plotcnt] = pct_50;
);
show(test_list);

回复:排除 Col 分位数计算中的行@LatentDataTiger ,来自 JMP 支持的反馈 (TS-00139301)
是的,这是一个错误。开发人员已验证这是 Col Quantile [& Col Median] 的缓存问题。其他 Col 函数没有这个问题。使用 Substitute 会在循环的每次迭代中创建一个新表达式,这样缓存就不会被错误使用。感谢您报告此问题,我会提交错误报告。
因此,在该行下,它不是Substitute ,而是通过Eval(Expr())的保护来修复错误。
@Arn_Cota [改编版本] 的很好的例子,说明了效果:
查看更多...Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
plot_param = {height, weight};
test_list = {};
For( plotcnt = 1, plotcnt <= N Items( plot_param ), plotcnt++,
// Without Exclude, returns correct values
pct_50_v0 = Col Quantile( Column( plot_param[plotcnt] ), 0.5 );
// With Exclude, returns the Quantile for height
pct_50_v1 = Col Quantile(
If( Excluded( Row State( Row() ) ),
.,
Column( plot_param[plotcnt] )
),
0.5
);
// With Eval and Substitute, returns correct values
pct_50_v2 = Eval(
Substitute(
Expr(
Col Quantile(
If( Excluded( Row State( Row() ) ),
.,
Column( plot_param[plotcnt] )
),
0.5
)
),
1, 1
)
);
// use Eval(Expr() to protect the expression against inappropriate caching
pct_50_v3 = Eval(Expr(Col Quantile(
If( Excluded( Row State( Row() ) ),
.,
Column( plot_param[plotcnt] )
),
0.5
)));
// Show different versions
Show(
plotcnt,
Column( plot_param[plotcnt] ),
pct_50_v0,
pct_50_v1,
pct_50_v2,
pct_50_v3
);
test_list[plotcnt] = pct_50_v3;
); 回复:排除 Col 分位数计算中的行JMP 中的表达式处理中添加了示例/解决方法:Tipps 和 Trapdoors