2011-09-21 36 views
4

在硬幣包中使用權值參數時,我收到了一些不一致的結果。特別是對於kruskal_test和spearman_test函數。硬幣包錯誤或錯誤的提示問題?

通過定期的數據一切正常,並在統計數據包kruskal.test同意:

> x <- xtabs(~gear + vs,data=mtcars) 
> df <- as.data.frame.table(x) 
> kruskal_test(gear ~ as.factor(vs),data=mtcars) 

    Asymptotic Kruskal-Wallis Test 

data: gear by as.factor(vs) (0, 1) 
chi-squared = 2.4768, df = 1, p-value = 0.1155 
> kruskal.test(gear ~ as.factor(vs),data=mtcars) 

    Kruskal-Wallis rank sum test 

data: gear by as.factor(vs) 
Kruskal-Wallis chi-squared = 2.4768, df = 1, p-value = 0.1155 

但是,當同樣的數據反饋與頻率權重kruskal_test,我得到一個不正確的結果。

> kruskal_test(as.numeric(df[[1]]) ~ df[[2]], 
+ weights=~as.integer(df[[3]])) 

    Asymptotic Kruskal-Wallis Test 

data: as.numeric(df[[1]]) by df[[2]] (0, 1) 
chi-squared = 1.3158, df = 1, p-value = 0.2513 

我設置此函數調用的方式有問題嗎?

+0

您是否試圖與商店主人聯繫嗎? –

+0

我做到了。沒有聽說過 –

+0

我希望Torsten Hothorn會迴應,因爲他是R-Core的成員。 –

回答

1

這確實是一個錯誤。 Thorsten迴應說,等級轉換沒有考慮到權重。下面的代碼演示測試產生相同的結果的非等級版本:

> oneway_test(as.integer(gear) ~ vs, data = df, weights = ~ Freq) 

    Asymptotic 2-Sample Permutation Test 

data: as.integer(gear) by vs (0, 1) 
Z = -1.1471, p-value = 0.2513 
alternative hypothesis: true mu is not equal to 0 

希望這將得到固定的未來。