作者Inderal10mg (Propranolol)
看板R_Language
标题[问题] 如何使matrix中的数值小数位不要进位
时间Thu Jun 27 14:51:12 2019
[问题类型]:
程式谘询(我想用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://webptt.com/cn.aspx?n=bbs/R_Language/M.1561618274.A.9BC.html
1F:→ andrew43: 这个例子,加0.6就可以解决。但你都用exact了需要靠加 06/27 19:27
2F:→ andrew43: 更正。它会自动round,且你都用exact需要靠加0.5修正吗? 06/27 19:28
3F:→ andrew43: 这种修正是传统上采近似分布才需要的吧? 06/27 19:29
4F:→ andrew43: exact方法先了解一下就会明白资料一定只能是整数。 06/27 19:31
5F:→ Inderal10mg: 谢谢,想知道有办法让它不要自动round吗? 06/28 10:32
6F:→ Inderal10mg: 我用?mcnemar.exact查询找不到可以调整的地方 06/28 10:33
7F:→ Inderal10mg: 因为要算odds ratio所以必须要加0.5修正zero count 06/28 10:34
8F:→ andrew43: 你说的odds ratio应该只是0.5/13.5,手算即可。 06/28 11:10
9F:→ Inderal10mg: 感谢 06/30 19:29