-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcomparison.Rmd
75 lines (59 loc) · 2.66 KB
/
comparison.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# Comparison #
## Data Summary ##
```{r}
comp <- read_xls(params$file, sheet = sheets$comp)
comp$GSP <- gsub(pattern="<|>",replacement="", x=comp$GSP, perl = TRUE) ## remove <,>
comp$GSP <- as.numeric(comp$GSP)
comp %<>%
## na.omit() %>%
filter(GSP >= info$lower & GSP <= info$upper & design == "p")
pander::pander(summary(comp[, c("AD", "GSP")]), caption = "\\label{tb:comp}Summary of Method Comparison Values")
```
```{r, fig.cap="\\label{fig:dens}Density plot for the method comparison"}
comp %>%
gather(method, result, AD:GSP) %>%
ggplot(aes(result, fill = method)) +
geom_density(alpha = 0.5) +
xlab(paste(params$analyte, info$units)) +
scale_fill_discrete(name = "Method")
```
```{r, fig.cap="\\label{fig:dens_inst}Density plot for the method comparison by instrument"}
comp %>%
gather(method, result, AD:GSP) %>%
ggplot(aes(result, fill = method)) +
geom_density(alpha = 0.5) +
facet_grid(instrument ~.) +
xlab(paste(params$analyte, info$units)) +
scale_fill_discrete(name = "Method")
ggsave("density.pdf")
```
\FloatBarrier
### Paired T-test ###
```{r}
pander::pander(t.test(comp$AD, comp$GSP, paired = TRUE),
caption = "\\label{tab:paired}Paired T-test")
```
### Regression Analysis ###
```{r, fig.cap="\\label{fig:dem}Deming regression"}
comp.deming <- mcreg(x = comp$AD, y =comp$GSP, error.ratio = 1, alpha = 0.05,
mref.name = "AD", mtest.name = "GSP", sample.names = NULL,
method.reg = "Deming", method.ci = "bootstrap",
method.bootstrap.ci = "BCa",
nsamples = 999, rng.seed = NULL, rng.kind = "Mersenne-Twister", iter.max = 30,
threshold = 1e-06, na.rm = TRUE, NBins = 1e+06)
plot(comp.deming, x.lab = "AD", y.lab = "GSP", main=paste("Pooled", params$analyte,"Method Comparision"))
```
```{r, fig.cap="\\label{fig:dem_inst}Deming regression by instrument"}
for (inst in c(344, 348, 349)){
comp_inst<- comp %>%
filter(instrument == inst)
comp_inst.deming <- mcreg(x = comp_inst$AD, y =comp_inst$GSP, error.ratio = 1, alpha = 0.05,
mref.name = "AD", mtest.name = "GSP", sample.names = NULL,
method.reg = "Deming", method.ci = "bootstrap",
method.bootstrap.ci = "BCa",
nsamples = 999, rng.seed = NULL, rng.kind = "Mersenne-Twister", iter.max = 30,
threshold = 1e-06, na.rm = TRUE, NBins = 1e+06)
plot(comp_inst.deming, x.lab = "AD", y.lab = "GSP", main=paste(inst, params$analyte, "Method Comparision" ))
}
```
\FloatBarrier