有人可以帮我这个吗?我想使用R制作一个Bland-Altman图,对于我的数据的两列,在下面的数据中列是前臂和前臂2,但我不知道如何。
>data_2
Sex Forearm Height Age Forearm2
1 Male 17 182 55 26
2 Male 18 185 103 28
3 Male 20 171 49 25
4 Male 18 176 58 25
5 Male 21 158 57 23
6 Female 21 155 43 25
7 Male 18 199 114 29
8 Male 19 176 90 25
9 Male 17 191 68 29
10 Male 23 176 52 25
11 Female 19 153 34 24
12 Female 19 160 56 26
13 Male 19 170 47 25
14 Male 22 178 62 25
15 Female 21 174 49 27
16 Male 22 162 40 24
17 Female 23 172 82 27
18 Female 19 185 99 28
19 Female 18 168 66 25
20 Female 17 155 45 24
21 Male 17 182 83 27
22 Female 17 164 42 25
23 Female 18 162 73 26
24 Male 18 185 68 28
25 Female 18 146 50 23
26 Female 23 169 47 25
27 Female 18 160 51 24
28 Female 18 170 69 25
29 Male 24 185 57 27
30 Male 24 167 46 24
31 Female 25 169 47 26
32 Female 24 164 50 25
33 Female 21 155 47 235
34 Female 24 158 37 24
35 Female 23 177 88 27
36 Female 23 155 36 24
37 Male 19 170 47 24
38 Female 21 170 48 26
39 Female 23 160 74 25
40 Male 21 180 100 26
41 Male 19 186 95 27
42 Male 21 181 65 26
我曾尝试使用我在互联网(维基百科)上找到的方法多次使用它,但我不知道哪里出错了。这是我到目前为止所做的,但我一直收到错误信息。
BAplot=function(data_2$forearm,data_2$forearm2){
(data_2$forearm,data_2$forearm2,
xlab="Mean size(mm)",
ylab="Difference(mm)",
ylim=c(15,40), pch=42)
abline(0,0)}
Error: unexpected '$' in "BAplot=function(data_2$"
答案 0 :(得分:5)
如果您在google上输入Bland-Altman plot using R
,您会找到'MethComp'软件包并查看内部有一个名为BlandAltman
的函数,它可以完全按照您的要求执行。
> library(MethComp)
> with(df, BlandAltman(Forearm, Forearm2))
NOTE:
'AB.plot' and 'BlandAltman' are deprecated,
and likely to disappear in a not too distant future,
use 'BA.plot' instead.
Limits of agreement:
Forearm - Forearm2 2.5% limit 97.5% limit SD(diff)
-10.33333 -75.01517 54.34850 32.34092
请注意,BA.plot
功能已存在,请注意NOTE
。它将产生以下情节: