-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
194 lines (151 loc) · 4.13 KB
/
README.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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
---
title: "NONMEM workshop"
author: "Sungpil Han, Kyun-Seop Bae"
date: "`r Sys.Date()`"
output:
html_document:
df_print: paged
editor_options:
chunk_output_type: console
---
```{r setup, include = FALSE}
library(knitr)
library(readr)
library(dplyr)
library(tidyr)
library(purrr)
library(nmw)
library(lattice)
inputFirst <- read_csv("result/inputFirst.csv",
col_names = c('name', 'value'),
skip = 1) %>%
print()
input <- inputFirst %>%
spread(name, value)
NMDataset <- input$Dataset
METHOD <- input$Method
nTheta <- as.numeric(input$nTheta)
nEta <- as.numeric(input$nEta)
nEps <- as.numeric(input$nEps)
# Initial Value: Theta
THETAinit <- as.numeric(unlist(strsplit(input$THETAinit, split=",")))
# Initial Value: Omega (Eta)
OMinit <- matrix(as.numeric(unlist(strsplit(input$OMinit, split=","))),
nrow=nEta,
ncol=nEta)
# Initial Value: Sigma (Epsilon)
SGinit <- matrix(as.numeric(unlist(strsplit(input$SGinit, split=","))),
nrow=nEps,
ncol=nEps)
LB <- rep(0, nTheta)
UB <- rep(1000000, nTheta)
```
![Cover](cover.jpg)
<https://github.com/asancpt/edison-nmw>
license: GPL-3
## Introduction
NONMEM Workshop 2017, 2018에서 사용된 nmw 패키지를 사용한 Edison 사이언스 앱입니다.
## Result
A table (head) and a figure of input dataset is shown below.
### Initial values
```{r}
kable(inputFirst, format = "markdown")
```
### Input Table
```{r include = FALSE}
#enableJIT(3)
##setwd("C:/NMW2017/03-Emax")
if (NMDataset == "Emax"){
DataFile <- "03-Emax/SimData.CSV"
DataAll <- read.csv(DataFile)
} else if (NMDataset == "Theoph") {
DataAll <- datasets::Theoph %>%
select(Subject, Time, conc) %>%
set_names('ID', 'TIME', 'DV') %>%
print()
}
```
```{r}
kable(head(DataAll, n = 20), caption = "input data", format = "markdown")
```
### Figure
```{r figure, include = TRUE}
if (NMDataset == "Emax") xyplot(DV ~ log(CE) | ID, data=DataAll, type="b")
if (NMDataset == "Theoph") {
xyplot(DV~TIME|ID,
data=DataAll,
type="b",
index.cond=list(order(as.numeric(levels(unique(DataAll$ID))))))
}
```
### Method Calculation
- Dataset: `r NMDataset`
- Method: `r METHOD`
```{r ZERO}
PREDFILE <- ifelse(NMDataset == "Emax", "03-Emax/PRED.R", "04-THEO/PRED.R")
source(PREDFILE)
FGD <- deriv(expr = ~ DOSE/
(TH2*exp(ETA2)) *
TH1*exp(ETA1)/
(TH1*exp(ETA1) - TH3*exp(ETA3)) *
(exp(-TH3*exp(ETA3)*TIME)-exp(-TH1*exp(ETA1)*TIME)),
namevec = c("ETA1","ETA2","ETA3"),
function.arg = c("TH1", "TH2", "TH3",
"ETA1", "ETA2", "ETA3",
"DOSE", "TIME"),
func=TRUE,
hessian=TRUE)
H <- deriv(~F + F*EPS1 + EPS2, c("EPS1", "EPS2"),
function.arg=c("F", "EPS1", "EPS2"),
func=TRUE)
InitPara <- nmw::InitStep(DataAll,
THETAinit=THETAinit,
OMinit=OMinit,
SGinit=SGinit,
LB=LB,
UB=UB,
Pred=PRED,
METHOD=METHOD)
(EstRes = EstStep()) # 0.6200359 secs, 0.4930282 secs
(CovRes = CovStep())
#PostHocEta() # FinalPara from EstStep()
#get("EBE", envir=e)
```
## Appendix
### Examples for Initial Values
#### Emax
```
PRED = function(THETA, ETAi, DATAi)
{
CE = DATAi[,"CE"]
CE50 = as.numeric(THETA[1] * exp(ETAi[1]))
BASE = as.numeric(THETA[2])
F = BASE * (1 - CE/(CE50 + CE))
G1 = BASE * CE * CE50 / (CE50 + CE)^2
H1 = rep(1, nrow(DATAi))
D11 = (-2*CE50/(CE + CE50) + 1) * G1
return(cbind(F, G1, H1, D11))
}
nTheta = 2
nEta = 1
nEps = 1
THETAinit = 10, 100
OMinit = 0.2
SGinit = 1
```
#### Theoph (ZERO, CONC)
```
nTheta = 3
nEta = 3
nEps = 2
THETAinit = 2, 50, 0.1
OMinit = 0.2, 0.1, 0.1, 0.1, 0.2, 0.1, 0.1, 0.1, 0.2
SGinit = 0.1, 0, 0, 0.1
```
#### Theoph (LAPL)
```
THETAinit = 4, 50, 0.2
```
The other values are the same with those of `Theoph (ZERO, CONC)`.
## References
`r paste(read_lines('bibliography.txt'), collapse = "\n")`