-
Notifications
You must be signed in to change notification settings - Fork 0
/
report.rmd
172 lines (123 loc) · 5.64 KB
/
report.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
---
title: "**NIST ABACUS Chemical Analysis Package: Measurement Calibration**"
author: "Pre-Experiment"
date: "`r Sys.Date()`"
output: pdf_document
params:
bayes: NA
condition: NULL
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
**MODEL RESULTS**
```{r,echo=FALSE,comment=NA,message=FALSE,results='asis'}
hr()
cat(' \n')
cat(' \n')
cat(' The posterior mean:\n',round(mean(params$bayes[["mcmcout"]]),5))
cat(' \n')
cat( 'The standard uncertainty:\n',round(sd(params$bayes[["mcmcout"]]),5))
cat(' \n')
cat( 'The posterior median:\n',round(median(params$bayes[["mcmcout"]]),5))
credible.interval1=quantile(params$bayes[["mcmcout"]],0.025)
credible.interval2=quantile(params$bayes[["mcmcout"]],0.975)
cat(' \n')
cat('The 95% credible interval ranges from:\n', round(credible.interval1,5),'to',round(credible.interval2,5))
cat(' \n')
cat(' \n')
if (params$condition == "LR") {
cat(' \n')
cat(' \n')
cat('R-squared:\n',round(params$bayes[["rsq"]],5),' . ','Intercept:\n','mean=',round(params$bayes[["outa"]][["mean"]],5),',','sd= ',round(params$bayes[["outa"]][["sd"]],5),'.','Slope:\n','mean=',round(params$bayes[["outb"]][["mean"]],5),',','sd= ',round(params$bayes[["outb"]][["sd"]],5))
cat(' \n')
cat(' \n')
} else if (params$condition == "RF")
{
cat('Respond Factor: \n', 'mean=',round(params$bayes[["outb"]][["mean"]],5),',','sd= ',round(params$bayes[["outb"]][["sd"]],5))
cat(' \n')
cat(' \n')
}
cat('The estimated parameters for the design of experiment(the 95% credible interval):')
cat(' \n')
xnew_vals <- params$bayes[["xnew"]]
cat('-The expected approximate value of the measurand, quantity of A:', paste(round(xnew_vals, 5), collapse=", "), "\n")
cat(' \n')
betal_vals <- params$bayes[["betal"]]
betau_vals <- params$bayes[["betau"]]
cat('-The Slope of calibration line: min', paste0('c(', paste(round(betal_vals, 5), collapse=", "), ')'), ', max', paste0('c(', paste(round(betau_vals, 5), collapse=", "), ')'), "\n")
cat(' \n')
waca_vals <- params$bayes[["waca"]]
wacb_vals <- params$bayes[["wacb"]]
cat('-Target calibration region;x-axis range in terms of concentrations of A:I in the calibration solutions:', 'min', paste0('c(', paste(round(waca_vals, 5), collapse=", "), ')'), ', max', paste0('c(', paste(round(wacb_vals, 5), collapse=", "), ')'), "\n")
cat(' \n')
vyl_vals <- params$bayes[["vyl"]]
vyu_vals <- params$bayes[["vyu"]]
cat('-Expected standard deviation of peak area ratios (A:I) from a calibration solution; (uy):\n', 'min', paste0('c(', paste(round(vyl_vals, 5), collapse=", "), ')'), ', max', paste0('c(', paste(round(vyu_vals, 5), collapse=", "), ')'), "\n")
cat(' \n')
cat('-Expected standard uncertainty of the concentration ratios of A:I in the calibration experiment; (ux):\n', 'user input')
cat(' \n')
vil_vals <- params$bayes[["vil"]]
viu_vals <- params$bayes[["viu"]]
cat('-Expected relative standard uncertainty of the concentration of I in samples measured for the quantitation experiment; (ui):\n',
'min ',
paste0('c(', paste(round(vil_vals, 5), collapse=", "), ')'),
', max ',
paste0('c(', paste(round(viu_vals, 5), collapse=", "), ')'),
"\n\n")
cat(' \n')
etal_vals <- params$bayes[["etal"]]
etau_vals <- params$bayes[["etau"]]
cat('-Expected relative standard uncertainty of the concentration ratios of A:I in the calibration experiment (rux):\n',
'min ',
paste0('c(', paste(round(etal_vals, 5), collapse=", "), ')'),
', max ',
paste0('c(', paste(round(etau_vals, 5), collapse=", "), ')'),
"\n\n")
cat(' \n')
# For vsl and vsu
vsl_vals <- params$bayes[["vsl"]]
vsu_vals <- params$bayes[["vsu"]]
cat('-Expected between-sample variability (standard deviation) of peak area ratios (A:I) from the quantitation experiment(us):\n',
'min ',
paste0('c(', paste(round(vsl_vals, 5), collapse=", "), ')'),
', max ',
paste0('c(', paste(round(vsu_vals, 5), collapse=", "), ')'),
"\n\n")
cat(' \n')
# Extract data length.
nfile <- length(params$bayes[["wac"]])
#
if (nfile == 1) {
# Single plot
plot(params$bayes[["wac"]], params$bayes[["rac"]], main = "Calibration Plot", pch=19, col=c("forestgreen", "tomato"), xlab="Wac", ylab="Rac")
text(params$bayes[["wac"]], params$bayes[["rac"]], paste(round(params$bayes[["wac"]], 2), round(params$bayes[["rac"]], 2), sep=", "), cex=0.8)
lines(params$bayes[["wac"]], params$bayes[["cl"]], type="l", col="steelblue", lty="dashed")
lines(params$bayes[["wac"]], params$bayes[["cu"]], type="l", col="steelblue", lty="dashed")
abline(a=params$bayes[["linea"]], b=params$bayes[["lineb"]], col="red")
#
#
}else {
}
cat(' \n')
cat(' \n')
cat(' \n')
plot(density(params$bayes[["mcmcout"]]),col="violet",main="Posterior Distribution",xlab = "WD",lwd=3)
z = density(params$bayes[["mcmcout"]],n=4096)
L = quantile(params$bayes[["mcmcout"]], probs=0.025)
U = quantile(params$bayes[["mcmcout"]], probs=0.975)
iS = which.min(abs(z$x-L))
iE = which.min(abs(z$x-U))
xp = c(L, U, z$x[iE:iS])
yp = c(0, 0, z$y[iE:iS])
polygon(xp, yp, border=F, col="thistle1")
points(median(params$bayes[["mcmcout"]]),
min(z$y)+0.4*par()$cxy[2], pch=19, bg="Blue", col="slateblue4")
segments(L, 0, U, 0, lwd=2, col="slateblue4")
lines(z$x, z$y, type="l", col="violet", lwd=3)
##trace plot
traceColors=rainbow(1)
plot(params$bayes[["mcmcout"]],main="Traceplot",type="l",ylab = "WD")
#plot(density(params$bayes[["mcmcout"]]),col="violet",main="Posterior Distribution",xlab = "WD",lwd=3)
#
```