2014-01-15 73 views
0

如何測試訂購組的趨勢。我使用prop.trend.test但它並沒有整理成組,不給的sum of ranks預期輸出,z value ... 我使用這個命令 prop.trend.test (birthweight2$lbw2 ,birthweight2$gestwkgp)跨訂購組的趨勢測試

我有這樣的數據集

lbw2   gestwkgp 
normal birth weight 3 
normal birth weight 3 
normal birth weight 3 
normal birth weight 4 
normal birth weight 3 
normal birth weight 3 
normal birth weight 3 
normal birth weight 4 
low birth weight 2 
normal birth weight 4 
normal birth weight 4 
normal birth weight 3 
normal birth weight 4 
normal birth weight 3 
normal birth weight 3 
normal birth weight 3 
normal birth weight 2 
normal birth weight 3 
normal birth weight 3 
normal birth weight 3 
normal birth weight 3 
normal birth weight 4 
normal birth weight 3 
normal birth weight 4 
normal birth weight 4 
normal birth weight 3 
normal birth weight 3 
normal birth weight 3 
low birth weight 3 
low birth weight 3 
normal birth weight 3 
normal birth weight 3 
normal birth weight 3 
low birth weight 1 
normal birth weight 3 
normal birth weight 4 
normal birth weight 3 
normal birth weight 4 
normal birth weight 3 
normal birth weight 3 
normal birth weight 4 
normal birth weight 3 
low birth weight 1 
normal birth weight 3 
normal birth weight 3 
normal birth weight 3 
normal birth weight 3 
normal birth weight 4 
normal birth weight 3 
normal birth weight 4 
normal birth weight 3 
normal birth weight 3 
normal birth weight 3 
normal birth weight 3 
normal birth weight 3 
normal birth weight 4 
normal birth weight 3 
normal birth weight 3 
normal birth weight 3 
normal birth weight 2 
normal birth weight 3 
low birth weight 2 
normal birth weight 3 
low birth weight 2 
low birth weight 2 
normal birth weight 4 
normal birth weight 2 
normal birth weight 3 
low birth weight 1 
normal birth weight 3 
normal birth weight 3 
low birth weight 1 
normal birth weight 3 
normal birth weight 3 
normal birth weight 3 
normal birth weight 3 
low birth weight 2 
normal birth weight 4 
low birth weight 2 
normal birth weight 3 
normal birth weight 3 
normal birth weight 3 
normal birth weight 2 
normal birth weight 3 
normal birth weight 3 
low birth weight 1 
normal birth weight 4 
normal birth weight 3 
normal birth weight 3 
normal birth weight 3 
normal birth weight 3 
normal birth weight 2 
normal birth weight 3 
normal birth weight 3 
normal birth weight 2 
normal birth weight 3 
normal birth weight 3 
normal birth weight 3 
normal birth weight 3 
normal birth weight 3 
normal birth weight 3 
normal birth weight 3 
normal birth weight 3 
normal birth weight 3 
normal birth weight 4 
+0

我會更清楚什麼樣的錯誤的來源是,如果你張貼'輸出(出生weight2)',但我想你不明白什麼類的gestwkgp2列是如何訂購的。 –

+0

gestwkgp是類因子,我不想將它用作分組變量 – Keniajin

回答

0

我不認爲這是prop.trend.test如何工作。您需要一個額外的限定符,將您的數據分爲前/後方案。然後你想看看這兩種情況下的低/正常體重是否有差異。考慮將你的問題定義爲2x2列聯表,其中列是前/後,行是重量類別。

    BEFORE AFTER 
low-weigh   freq  freq 
normal-weight  freq  freq 

那麼問題就變得像如果治療對體重沒有任何影響,因此函數的語法將變爲:

prop.trend.test(c(low-weight-after, normal-weight-after),c(rowSums(contingency_table)))