從單向分析中擷取數據我正在嘗試建立腳本來從單向分析中獲取 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 ); <BR />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 <FONT color="#FF0000">(untested)</FONT>.
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 值添加到正確行的程式碼是否有效...
謝謝。
回覆:從單向分析中擷取數據如果有人還想看看我如何將與性別和年齡工作相符的值加回表中:
//creates a new column
dt<<NEW column=""></NEW>
可能有一種更簡單或更簡潔的方法可以做到這一點,但它確實有效。 當我意識到原始年齡的資料類型與「數字」不匹配,而「LSD閾值矩陣」中的清單是「字元」時,嵌套的 if 語句和 for 迴圈也起作用了。
回覆:從單向分析中擷取數據不管怎樣,我清理了亂碼郵政從2011年開始。
回覆:從單向分析中擷取數據對於我們作為「最佳實踐」教授的內容,有一個強烈建議:不要使用絕對指數顯示樹圖中顯示的內容。 你可以這樣寫出正確的下標,為什麼不呢?因為這種方式很難寫、閱讀,因此也很難維護,而且很脆弱。 使用相對索引如我的解決方案所示。 它更容易編寫、閱讀(自我記錄?)和維護。 它的脆性也低得多。 自私一點,只考慮自己!
請記住,JMP 也會發生變化:版本在報告中引入新部分或移動部分,您更改平台首選項,其他人以不同的首選項使用您的腳本,等等。 防禦性腳本預計到這種變化。相對索引對此具有穩健性。
有些人認為這種選擇只是風格問題。 我希望他們永遠不會因為改變而遭受痛苦。
(並且不要讓我開始使用“發送到報告”解釋器指令......)
回覆:從單向分析中擷取數據這有效,謝謝!
因此,對於其他看到這裡的人......並確保我理解而不僅僅是複製和貼上程式碼,在:
f ages <SPAN class="token operator">=</SPAN> anova rpt<SPAN class="token punctuation">[</SPAN><SPAN class="token number">1</SPAN><SPAN class="token punctuation">]</SPAN><SPAN class="token punctuation">[</SPAN><SPAN class="token string">"LSD Threshold Matrix"</SPAN><SPAN class="token punctuation">]</SPAN><SPAN class="token punctuation">[</SPAN><SPAN class="token function">StringColBox</SPAN><SPAN class="token punctuation">(</SPAN><SPAN class="token number">1</SPAN><SPAN class="token punctuation">)</SPAN><SPAN class="token punctuation">]</SPAN> <SPAN class="token operator"><</SPAN><SPAN class="token operator"><</SPAN><SPAN class="token messages"> Get</SPAN><SPAN class="token punctuation">;</SPAN>
oneway 中的“By()”選項在報告中創建兩個單獨的實例,我猜測這就是為什麼“<
anova rpt<SPAN class="token punctuation">[</SPAN><SPAN class="token number">1</SPAN><SPAN class="token punctuation">]</SPAN>
指向建立單向時從 'By(:sex)' 建立的第一個群組,即 'F','anova rpt[2]' 指的是群組 2 'M'。時間腳本指南中的原始腳本不需要它,因為報告中只有一個部分需要處理,而它是一個簡單的雙變量?
然後是該段:
<SPAN class="token punctuation">[</SPAN><SPAN class="token string">"LSD Threshold Matrix"</SPAN><SPAN class="token punctuation">]</SPAN><SPAN class="token punctuation">[</SPAN><SPAN class="token function">StringColBox</SPAN><SPAN class="token punctuation">(</SPAN><SPAN class="token number">1</SPAN><SPAN class="token punctuation">)</SPAN><SPAN class="token punctuation">]</SPAN>
讓 jmp 直接跳到報告的「LSD 閾值矩陣」部分並重置編號方案,這就是字串列現在由 ...Box(1) 引用的原因,但對於整個樹結構來說,它是...框(5)。這三種方法都是從樹結構中獲取參考女性年齡清單的等效方法:
f ages <SPAN class="token operator">=</SPAN> anova rpt<SPAN class="token punctuation">[</SPAN><SPAN class="token number">1</SPAN><SPAN class="token punctuation">]</SPAN><SPAN class="token punctuation">[</SPAN><SPAN class="token string">"LSD Threshold Matrix"</SPAN><SPAN class="token punctuation">]</SPAN><SPAN class="token punctuation">[</SPAN><SPAN class="token function">StringColBox</SPAN><SPAN class="token punctuation">(</SPAN><SPAN class="token number">1</SPAN><SPAN class="token punctuation">)</SPAN><SPAN class="token punctuation">]</SPAN> <SPAN class="token operator"><</SPAN><SPAN class="token operator"><</SPAN><SPAN class="token messages"> Get</SPAN><SPAN class="token punctuation">;<BR />f ages = anova rpt[1][Outline Box(9)][StringColBox(1)] << Get;<BR />f ages = anova rpt[1][StringColBox(5)] << Get;<BR /></SPAN>
然後如果從單向方式註解掉By(:sex),樹結構就簡化了:
ages <SPAN class="token operator">=</SPAN> anova rpt[1]<SPAN class="token punctuation">[</SPAN><SPAN class="token function">StringColBox</SPAN><SPAN class="token punctuation">(5</SPAN><SPAN class="token punctuation">)</SPAN><SPAN class="token punctuation">]</SPAN> <SPAN class="token operator"><</SPAN><SPAN class="token operator"><</SPAN><SPAN class="token messages"> Get</SPAN><SPAN class="token punctuation">;<BR />ages = anova rpt[StringColBox(5)] << Get;<BR /></SPAN>
現在兩者都可以工作,因為 [1] 已被理解,並且不需要指定,因為 [2] 甚至不再是一個選項。
回覆:從單向分析中擷取數據當然,有適用於所有 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;