aboutsummaryrefslogtreecommitdiff
path: root/vignettes/web_only/dimethenamid_2018.R
blob: 625cceb8ad8613e5d63e548aa13ea6a4928147fd (plain) (blame)
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
## ---- include = FALSE---------------------------------------------------------
require(knitr)
options(digits = 5)
opts_chunk$set(
  comment = "",
  tidy = FALSE,
  cache = TRUE
)

## ----dimethenamid_data--------------------------------------------------------
library(mkin)
dmta_ds <- lapply(1:8, function(i) {
  ds_i <- dimethenamid_2018$ds[[i]]$data
  ds_i[ds_i$name == "DMTAP", "name"] <-  "DMTA"
  ds_i$time <- ds_i$time * dimethenamid_2018$f_time_norm[i]
  ds_i
})
names(dmta_ds) <- sapply(dimethenamid_2018$ds, function(ds) ds$title)
dmta_ds[["Borstel"]] <- rbind(dmta_ds[["Borstel 1"]], dmta_ds[["Borstel 2"]])
dmta_ds[["Borstel 1"]] <- NULL
dmta_ds[["Borstel 2"]] <- NULL
dmta_ds[["Elliot"]] <- rbind(dmta_ds[["Elliot 1"]], dmta_ds[["Elliot 2"]])
dmta_ds[["Elliot 1"]] <- NULL
dmta_ds[["Elliot 2"]] <- NULL

## ----f_parent_mkin------------------------------------------------------------
f_parent_mkin_const <- mmkin(c("SFO", "DFOP"), dmta_ds,
  error_model = "const", quiet = TRUE)
f_parent_mkin_tc <- mmkin(c("SFO", "DFOP"), dmta_ds,
  error_model = "tc", quiet = TRUE)

## ----f_parent_mkin_sfo_const--------------------------------------------------
plot(mixed(f_parent_mkin_const["SFO", ]))

## ----f_parent_mkin_dfop_const-------------------------------------------------
plot(mixed(f_parent_mkin_const["DFOP", ]))

## ----f_parent_mkin_dfop_const_test--------------------------------------------
plot(mixed(f_parent_mkin_const["DFOP", ]), test_log_parms = TRUE)

## ----f_parent_mkin_dfop_tc_test-----------------------------------------------
plot(mixed(f_parent_mkin_tc["DFOP", ]), test_log_parms = TRUE)

## ----f_parent_nlme, warning = FALSE-------------------------------------------
f_parent_nlme_sfo_const <- nlme(f_parent_mkin_const["SFO", ])
#f_parent_nlme_dfop_const <- nlme(f_parent_mkin_const["DFOP", ]) # error
f_parent_nlme_sfo_tc <- nlme(f_parent_mkin_tc["SFO", ])
f_parent_nlme_dfop_tc <- nlme(f_parent_mkin_tc["DFOP", ])

## ----f_parent_nlme_logchol, warning = FALSE, eval = FALSE---------------------
#  f_parent_nlme_sfo_const_logchol <- nlme(f_parent_mkin_const["SFO", ],
#    random = pdLogChol(list(DMTA_0 ~ 1, log_k_DMTA ~ 1)))
#  anova(f_parent_nlme_sfo_const, f_parent_nlme_sfo_const_logchol) # not better
#  f_parent_nlme_dfop_tc_logchol <- update(f_parent_nlme_dfop_tc,
#    random = pdLogChol(list(DMTA_0 ~ 1, log_k1 ~ 1, log_k2 ~ 1, g_qlogis ~ 1)))
#  # using log Cholesky parameterisation for random effects (nlme default) does
#  # not converge and gives lots of warnings about the LME step not converging

## ----AIC_parent_nlme----------------------------------------------------------
anova(
  f_parent_nlme_sfo_const, f_parent_nlme_sfo_tc, f_parent_nlme_dfop_tc
)

## ----plot_parent_nlme---------------------------------------------------------
plot(f_parent_nlme_dfop_tc)

Contact - Imprint