[問題] 如何使matrix中的數值小數位不要進位
[問題類型]:
程式諮詢(我想用R 做某件事情,但是我不知道要怎麼用R 寫出來)
[軟體熟悉度]:
入門
[問題敘述]:
使用package"exact2x2"執行Exact McNemar's test時,因細格中有零,
按照文獻建議各加0.5才執行計算,但是r會將0.5視為0,想請教前輩們如何
讓其維持在0.5的狀態下計算Odds ratio與95% confidence interval,謝謝。
[程式範例]:
# 使用套件
library(exact2x2)
# 輸入計算數值
x=matrix(c(18.5,13.5,0.5,4.5),2,2)
#計算結果
mcnemar.exact(x)
#結果
Exact McNemar test (with central confidence intervals)
data: x
b = 0, c = 14, p-value = 0.0001221
alternative hypothesis: true odds ratio is not equal to 1
95 percent confidence interval:
0.0000000 0.3014661
sample estimates:
odds ratio
0
Warning message:
In exact2x2(x = x, alternative = "two.sided", tsmethod = "central", :
'x' has been rounded to integer: Mean relative difference: 0.05405405
[環境敘述]:
R version 3.5.3 (2019-03-11)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17763)
Matrix products: default
locale:
[1] LC_COLLATE=Chinese (Traditional)_Taiwan.950
[2] LC_CTYPE=Chinese (Traditional)_Taiwan.950
[3] LC_MONETARY=Chinese (Traditional)_Taiwan.950
[4] LC_NUMERIC=C
[5] LC_TIME=Chinese (Traditional)_Taiwan.950
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] exact2x2_1.6.3 exactci_1.3-3 ssanv_1.1
loaded via a namespace (and not attached):
[1] compiler_3.5.3
[關鍵字]:
exact2x2, exact mcnemar test
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.116.67.123 (臺灣)
※ 文章網址: https://www.ptt.cc/bbs/R_Language/M.1561618274.A.9BC.html
→
06/27 19:27,
5年前
, 1F
06/27 19:27, 1F
→
06/27 19:28,
5年前
, 2F
06/27 19:28, 2F
→
06/27 19:29,
5年前
, 3F
06/27 19:29, 3F
→
06/27 19:31,
5年前
, 4F
06/27 19:31, 4F
→
06/28 10:32,
5年前
, 5F
06/28 10:32, 5F
→
06/28 10:33,
5年前
, 6F
06/28 10:33, 6F
→
06/28 10:34,
5年前
, 7F
06/28 10:34, 7F
→
06/28 11:10,
5年前
, 8F
06/28 11:10, 8F
→
06/30 19:29,
5年前
, 9F
06/30 19:29, 9F
R_Language 近期熱門文章
PTT數位生活區 即時熱門文章