我正在尝试创建一个脚本来从单向分析中获取 p 值,并将其放入用于分析的表中的新列中。
我查看了 JMP 13 脚本编写指南,在第 690 页上,有“从分析中提取值到报告中”,这似乎就是我想要的。 然而,以此为指导,它似乎不适用于单向和方差分析......
以下是我在尝试对代码进行故障排除时修改的列出的脚本,以使用 bigclass 示例数据集:
Deletesymbols();
dt=Open("$SAMPLE_DATA\Big Class.jmp");
//creates a oneway analysis of big class similar how my data will be interpreted
anova=Oneway(
Y(:height),
X(:age),
With Control(1, {12}),
Means(1), Mean Diamonds(1), Comparison Circles(1),
By(:sex)
);
anova<<show tree structure;
/*
Female LDS threshold results are in OultineBox(9), Levels (age) is StringColBox(5), pValues are NumberColBox(15)
Male LDS threshold results are in OultineBox(18), Levels (age) is StringColBox(10), pValues are NumberColBox(30)
*/
// Should create a report that I can use to extract data from the anova analysis based off the original script
report(anova) [Outline Box(9)] << Close( 0 ); report(anova) [Outline Box(18)] << Close( 0 );
reportanova = anova << Report;
// Should extract the level (age) and pvalues for females
agef = reportanova[Outline Box(9)][String Col Box(5)] << Getaslist;
pvalsf = reportanova[Outline Box(9)][NumberColBox(15)] << Getaslist;
// Should extract the level (age) pvalues for males
agem = reportanova[Outline Box(18)][String Col Box(10)] << Getaslist;
pvalsm = reportanova[Outline Box(18)][NumberColBox(30)] << Getaslist;
//column creation to recieve extracted data
dt<<new column("p-value",Numeric, "Continuous");
//should add the collected p-value to the data table in the new column, matched to the correct row based on sex and age (untested).
For Each Row( p-value =
match(sex,
"f",match(age,
show(agef[1]),show(pvalsf[1]),
show(agef[2]),show(pvalsf[2]),
show(agef[3]),show(pvalsf[3]),
show(agef[4]),show(pvalsf[4]),
show(agef[5]),show(pvalsf[5]),
show(agef[6]),show(pvalsf[6]),
),
"m",match(age,
show(agem[1]),show(pvalsm[1]),
show(agem[2]),show(pvalsm[2]),
show(agem[3]),show(pvalsm[3]),
show(agem[4]),show(pvalsm[4]),
show(agem[5]),show(pvalsm[5]),
show(agem[6]),show(pvalsm[6]),
),
);*/
但是嵌入日志在将方差分析放入报告时出现错误:
Send 在访问或评估 'Send' 时期望可编写脚本的对象,Report( anova )[Outline Box( 9 )] << /*###*/Close( 0 ) /*###*/
调试器在同一位置失败并将这些作为变量:
多变的价值
方差分析 {Oneway[],单程[]}
dt数据表(“大类”)
reportanova {DisplayBox[OutlineBox], DisplayBox[OutlineBox]}
所以我只能猜测,适用于 Bivariate 的方法不适用于 Oneway。我什至更改了变量,将方差分析缩短为方差分析,以防变量/命令/某些内容不匹配,但它仍然失败。有一个上一篇文章从 2011 年开始,有一个示例代码,但它被字体信息弄乱了,无法在 Word、jmp 脚本窗口或另存为 html 文件中清除,因此我实际上可以阅读它......
我必须先解决这个问题,然后才能查看将 p 值添加到正确行的代码是否有效...
谢谢。
这篇帖子最初是用 English (US) 书写的,已做计算机翻译处理。当您回复时,文字也会被翻译成 English (US)。
已接受的解答
当然,有适用于所有 JMP 平台(报告)的通用规则和语法,但组成(即特定的嵌套显示框)会有所不同。 尝试这个方法:
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\Big Class.jmp" );
//creates a oneway analysis of big class similar how my data will be interpreted
anova = dt << Oneway(
Y( :height ),
X( :age ),
With Control( 1, {12} ),
Means( 1 ),
Mean Diamonds( 1 ),
Comparison Circles( 1 ),
By( :sex )
);
anova rpt = anova << Report;
f ages = anova rpt[1]["LSD Threshold Matrix"][StringColBox(1)] << Get;
f pVal = anova rpt[1]["LSD Threshold Matrix"][NumberColBox(2)] << Get;
m ages = anova rpt[2]["LSD Threshold Matrix"][StringColBox(1)] << Get;
m pVal = anova rpt[2]["LSD Threshold Matrix"][NumberColBox(2)] << Get;
当然,有适用于所有 JMP 平台(报告)的通用规则和语法,但组成(即特定的嵌套显示框)会有所不同。 尝试这个方法:
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\Big Class.jmp" );
//creates a oneway analysis of big class similar how my data will be interpreted
anova = dt << Oneway(
Y( :height ),
X( :age ),
With Control( 1, {12} ),
Means( 1 ),
Mean Diamonds( 1 ),
Comparison Circles( 1 ),
By( :sex )
);
anova rpt = anova << Report;
f ages = anova rpt[1]["LSD Threshold Matrix"][StringColBox(1)] << Get;
f pVal = anova rpt[1]["LSD Threshold Matrix"][NumberColBox(2)] << Get;
m ages = anova rpt[2]["LSD Threshold Matrix"][StringColBox(1)] << Get;
m pVal = anova rpt[2]["LSD Threshold Matrix"][NumberColBox(2)] << Get;
这篇帖子最初是用 English (US) 书写的,已做计算机翻译处理。当您回复时,文字也会被翻译成 English (US)。
这有效,谢谢!
因此,对于其他看到这里的人......并确保我理解而不仅仅是复制和粘贴代码,在:
f ages = anova rpt[1]["LSD Threshold Matrix"][StringColBox(1)] << Get;
oneway 中的“By()”选项在报告中创建两个单独的实例,我猜测这就是为什么“<
anova rpt[1]
指向创建单向时从 'By(:sex)' 创建的第一个组,即 'F','anova rpt[2]' 指的是组 2 'M'。时间脚本指南中的原始脚本不需要它,因为当它是一个简单的双变量时,报告中只有一个部分需要处理?
然后是该段:
["LSD Threshold Matrix"][StringColBox(1)]
让 jmp 直接跳到报告的“LSD 阈值矩阵”部分并重置编号方案,这就是字符串列现在由 ...Box(1) 引用的原因,但对于整个树结构来说,它是...框(5)。所有这三种方法都是从树结构中获取参考女性年龄列表的等效方法:
f ages = anova rpt[1]["LSD Threshold Matrix"][StringColBox(1)] << Get;f ages = anova rpt[1][Outline Box(9)][StringColBox(1)] << Get;f ages = anova rpt[1][StringColBox(5)] << Get;
然后如果从单向方式注释掉By(:sex),树结构就简化了:
ages = anova rpt[1][StringColBox(5)] << Get;ages = anova rpt[StringColBox(5)] << Get;
现在两者都可以工作,因为 [1] 已被理解,并且不需要指定,因为 [2] 甚至不再是一个选项。
这篇帖子最初是用 English (US) 书写的,已做计算机翻译处理。当您回复时,文字也会被翻译成 English (US)。
对于我们作为“最佳实践”教授的内容,有一个强烈建议:不要使用绝对指数显示树图中显示的内容。 你可以这样写出正确的下标,为什么不呢?因为这种方式很难编写、阅读,因此也很难维护,而且很脆弱。 使用相对索引如我的解决方案所示。 它更容易编写、阅读(自我记录?)和维护。 它的脆性也低得多。 自私一点,只考虑自己!
请记住,JMP 也会发生变化:版本在报告中引入新部分或移动部分,您更改平台首选项,其他人以不同的首选项使用您的脚本,等等。 防御性脚本预计到这种变化。相对索引对此具有稳健性。
有些人认为这种选择只是风格问题。 我希望他们永远不会因为变化而遭受痛苦。
(并且不要让我开始使用“发送到报告”解释器指令......)
这篇帖子最初是用 English (US) 书写的,已做计算机翻译处理。当您回复时,文字也会被翻译成 English (US)。