R : Copyright 2005, The R Foundation for Statistical Computing Version 2.1.1 (2005-06-20), ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for a HTML browser interface to help. Type 'q()' to quit R. > ### *
> ### > attach(NULL, name = "CheckExEnv") > assign(".CheckExEnv", as.environment(2), pos = length(search())) # base > ## add some hooks to label plot pages for base and grid graphics > setHook("plot.new", ".newplot.hook") > setHook("persp", ".newplot.hook") > setHook("grid.newpage", ".gridplot.hook") > > assign("cleanEx", + function(env = .GlobalEnv) { + rm(list = ls(envir = env, all.names = TRUE), envir = env) + RNGkind("default", "default") + set.seed(1) + options(warn = 1) + delayedAssign("T", stop("T used instead of TRUE"), + assign.env = .CheckExEnv) + delayedAssign("F", stop("F used instead of FALSE"), + assign.env = .CheckExEnv) + sch <- search() + newitems <- sch[! sch %in% .oldSearch] + for(item in rev(newitems)) + eval(substitute(detach(item), list(item=item))) + missitems <- .oldSearch[! .oldSearch %in% sch] + if(length(missitems)) + warning("items ", paste(missitems, collapse=", "), + " have been removed from the search path") + }, + env = .CheckExEnv) > assign("..nameEx", "__{must remake R-ex/*.R}__", env = .CheckExEnv) # for now > assign("ptime", proc.time(), env = .CheckExEnv) > grDevices::postscript("PK-Examples.ps") > assign("par.postscript", graphics::par(no.readonly = TRUE), env = .CheckExEnv) > options(contrasts = c(unordered = "contr.treatment", ordered = "contr.poly")) > options(warn = 1) > library('PK') > > assign(".oldSearch", search(), env = .CheckExEnv) > assign(".oldNS", loadedNamespaces(), env = .CheckExEnv) > cleanEx(); ..nameEx <- "AUC" > > ### * AUC > > flush(stderr()); flush(stdout()) > > ### Name: AUC > ### Title: Area Under the Concentration Time Curve > ### Aliases: AUC > ### Keywords: misc > > ### ** Examples > > ## example from Cawello W. (1998) page 71 > time <- c(0, 0.25, 0.5, 0.75, 1, 1.5, 2, 2.5, 3, 4, 5, 6) > conc <- c(0, 5.67, 20.6, 28.7, 22.5, 17.4, 17.7, 13.4, 11.0, 8.23, 5.14, 2.84) > AUC(conc=conc, time=time, exact=7, numtail=4) AUC AUMC observed 69.47000 156.1381 interpolated 71.16000 164.2481 infinity 75.73516 207.5503 > > > > cleanEx(); ..nameEx <- "biexp" > > ### * biexp > > flush(stderr()); flush(stdout()) > > ### Name: biexp > ### Title: Two-Phase Half-Life Estimation by Biexponential Model > ### Aliases: biexp > ### Keywords: misc > > ### ** Examples > > ## examples from Pinheiro J.C. and Bates D.M. (2000, page 279 and 280) > > subject <- structure(as.integer(c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5)), .Label = c("1", "4", "2", "5", "6", "3"), class = c("ordered", "factor")) > > time <- c(0.25, 0.5, 0.75, 1, 1.25, 2, 3, 4, 5, 6, 8, 0.25, 0.5, 0.75, 1, 1.25, 2, 3, 4, 5, 6, 8, 0.25, + 0.5, 0.75, 1, 1.25, 2, 3, 4, 5, 6, 8, 0.25, 0.5, 0.75, 1, 1.25, 2, 3, 4, 5, 6, 8, 0.25, 0.5, 0.75, 1, 1.25, + 2, 3, 4, 5, 6, 8, 0.25, 0.5, 0.75, 1, 1.25, 2, 3, 4, 5, 6, 8) > > conc <- c(1.5, 0.94, 0.78, 0.48, 0.37, 0.19, 0.12, 0.11, 0.08, 0.07, 0.05, 2.03, 1.63, 0.71, 0.7, 0.64, 0.36, + 0.32, 0.2, 0.25, 0.12, 0.08, 2.72, 1.49, 1.16, 0.8, 0.8, 0.39, 0.22, 0.12, 0.11, 0.08, 0.08, 1.85, 1.39, 1.02, + 0.89, 0.59, 0.4, 0.16, 0.11, 0.1, 0.07, 0.07, 2.05, 1.04, 0.81, 0.39, 0.3, 0.23, 0.13, 0.11, 0.08, 0.1, 0.06, + 2.31, 1.44, 1.03, 0.84, 0.64, 0.42, 0.24, 0.17, 0.13, 0.1, 0.09) > > data <- data.frame(subject, time, conc) > > result <- biexp(conc=data$conc, time=data$time) > print(result) $parms initial terminal halflife 0.2857337 2.0654415 slope 2.4258507 0.3355927 intercept 2.7731189 0.6066720 $conc [1] 1.50 0.94 0.78 0.48 0.37 0.19 0.12 0.11 0.08 0.07 0.05 2.03 1.63 0.71 0.70 [16] 0.64 0.36 0.32 0.20 0.25 0.12 0.08 2.72 1.49 1.16 0.80 0.80 0.39 0.22 0.12 [31] 0.11 0.08 0.08 1.85 1.39 1.02 0.89 0.59 0.40 0.16 0.11 0.10 0.07 0.07 2.05 [46] 1.04 0.81 0.39 0.30 0.23 0.13 0.11 0.08 0.10 0.06 2.31 1.44 1.03 0.84 0.64 [61] 0.42 0.24 0.17 0.13 0.10 0.09 $time [1] 0.25 0.50 0.75 1.00 1.25 2.00 3.00 4.00 5.00 6.00 8.00 0.25 0.50 0.75 1.00 [16] 1.25 2.00 3.00 4.00 5.00 6.00 8.00 0.25 0.50 0.75 1.00 1.25 2.00 3.00 4.00 [31] 5.00 6.00 8.00 0.25 0.50 0.75 1.00 1.25 2.00 3.00 4.00 5.00 6.00 8.00 0.25 [46] 0.50 0.75 1.00 1.25 2.00 3.00 4.00 5.00 6.00 8.00 0.25 0.50 0.75 1.00 1.25 [61] 2.00 3.00 4.00 5.00 6.00 8.00 $method [1] "biexp" attr(,"class") [1] "halflife" > plot(result) > > by(data$conc, data$subject, biexp, data$time) INDICES: 1 $parms initial terminal halflife 0.388338 4.1431705 slope 1.784907 0.1672987 intercept 2.029299 0.1915181 $conc [1] 1.50 0.94 0.78 0.48 0.37 0.19 0.12 0.11 0.08 0.07 0.05 1.50 0.94 0.78 0.48 [16] 0.37 0.19 0.12 0.11 0.08 0.07 0.05 1.50 0.94 0.78 0.48 0.37 0.19 0.12 0.11 [31] 0.08 0.07 0.05 1.50 0.94 0.78 0.48 0.37 0.19 0.12 0.11 0.08 0.07 0.05 1.50 [46] 0.94 0.78 0.48 0.37 0.19 0.12 0.11 0.08 0.07 0.05 1.50 0.94 0.78 0.48 0.37 [61] 0.19 0.12 0.11 0.08 0.07 0.05 $time [1] 0.25 0.50 0.75 1.00 1.25 2.00 3.00 4.00 5.00 6.00 8.00 0.25 0.50 0.75 1.00 [16] 1.25 2.00 3.00 4.00 5.00 6.00 8.00 0.25 0.50 0.75 1.00 1.25 2.00 3.00 4.00 [31] 5.00 6.00 8.00 0.25 0.50 0.75 1.00 1.25 2.00 3.00 4.00 5.00 6.00 8.00 0.25 [46] 0.50 0.75 1.00 1.25 2.00 3.00 4.00 5.00 6.00 8.00 0.25 0.50 0.75 1.00 1.25 [61] 2.00 3.00 4.00 5.00 6.00 8.00 $method [1] "biexp" attr(,"class") [1] "halflife" ------------------------------------------------------------ INDICES: 4 $parms initial terminal halflife 0.543796 3.4369554 slope 1.274646 0.2016748 intercept 2.197936 0.2549478 $conc [1] 1.85 1.39 1.02 0.89 0.59 0.40 0.16 0.11 0.10 0.07 0.07 1.85 1.39 1.02 0.89 [16] 0.59 0.40 0.16 0.11 0.10 0.07 0.07 1.85 1.39 1.02 0.89 0.59 0.40 0.16 0.11 [31] 0.10 0.07 0.07 1.85 1.39 1.02 0.89 0.59 0.40 0.16 0.11 0.10 0.07 0.07 1.85 [46] 1.39 1.02 0.89 0.59 0.40 0.16 0.11 0.10 0.07 0.07 1.85 1.39 1.02 0.89 0.59 [61] 0.40 0.16 0.11 0.10 0.07 0.07 $time [1] 0.25 0.50 0.75 1.00 1.25 2.00 3.00 4.00 5.00 6.00 8.00 0.25 0.50 0.75 1.00 [16] 1.25 2.00 3.00 4.00 5.00 6.00 8.00 0.25 0.50 0.75 1.00 1.25 2.00 3.00 4.00 [31] 5.00 6.00 8.00 0.25 0.50 0.75 1.00 1.25 2.00 3.00 4.00 5.00 6.00 8.00 0.25 [46] 0.50 0.75 1.00 1.25 2.00 3.00 4.00 5.00 6.00 8.00 0.25 0.50 0.75 1.00 1.25 [61] 2.00 3.00 4.00 5.00 6.00 8.00 $method [1] "biexp" attr(,"class") [1] "halflife" ------------------------------------------------------------ INDICES: 2 $parms initial terminal halflife 0.3110499 3.5567839 slope 2.2284118 0.1948803 intercept 2.8276198 0.4989065 $conc [1] 2.03 1.63 0.71 0.70 0.64 0.36 0.32 0.20 0.25 0.12 0.08 2.03 1.63 0.71 0.70 [16] 0.64 0.36 0.32 0.20 0.25 0.12 0.08 2.03 1.63 0.71 0.70 0.64 0.36 0.32 0.20 [31] 0.25 0.12 0.08 2.03 1.63 0.71 0.70 0.64 0.36 0.32 0.20 0.25 0.12 0.08 2.03 [46] 1.63 0.71 0.70 0.64 0.36 0.32 0.20 0.25 0.12 0.08 2.03 1.63 0.71 0.70 0.64 [61] 0.36 0.32 0.20 0.25 0.12 0.08 $time [1] 0.25 0.50 0.75 1.00 1.25 2.00 3.00 4.00 5.00 6.00 8.00 0.25 0.50 0.75 1.00 [16] 1.25 2.00 3.00 4.00 5.00 6.00 8.00 0.25 0.50 0.75 1.00 1.25 2.00 3.00 4.00 [31] 5.00 6.00 8.00 0.25 0.50 0.75 1.00 1.25 2.00 3.00 4.00 5.00 6.00 8.00 0.25 [46] 0.50 0.75 1.00 1.25 2.00 3.00 4.00 5.00 6.00 8.00 0.25 0.50 0.75 1.00 1.25 [61] 2.00 3.00 4.00 5.00 6.00 8.00 $method [1] "biexp" attr(,"class") [1] "halflife" ------------------------------------------------------------ INDICES: 5 $parms initial terminal halflife 0.2448041 3.1276014 slope 2.8314367 0.2216226 intercept 3.5662584 0.2915056 $conc [1] 2.05 1.04 0.81 0.39 0.30 0.23 0.13 0.11 0.08 0.10 0.06 2.05 1.04 0.81 0.39 [16] 0.30 0.23 0.13 0.11 0.08 0.10 0.06 2.05 1.04 0.81 0.39 0.30 0.23 0.13 0.11 [31] 0.08 0.10 0.06 2.05 1.04 0.81 0.39 0.30 0.23 0.13 0.11 0.08 0.10 0.06 2.05 [46] 1.04 0.81 0.39 0.30 0.23 0.13 0.11 0.08 0.10 0.06 2.05 1.04 0.81 0.39 0.30 [61] 0.23 0.13 0.11 0.08 0.10 0.06 $time [1] 0.25 0.50 0.75 1.00 1.25 2.00 3.00 4.00 5.00 6.00 8.00 0.25 0.50 0.75 1.00 [16] 1.25 2.00 3.00 4.00 5.00 6.00 8.00 0.25 0.50 0.75 1.00 1.25 2.00 3.00 4.00 [31] 5.00 6.00 8.00 0.25 0.50 0.75 1.00 1.25 2.00 3.00 4.00 5.00 6.00 8.00 0.25 [46] 0.50 0.75 1.00 1.25 2.00 3.00 4.00 5.00 6.00 8.00 0.25 0.50 0.75 1.00 1.25 [61] 2.00 3.00 4.00 5.00 6.00 8.00 $method [1] "biexp" attr(,"class") [1] "halflife" ------------------------------------------------------------ INDICES: 6 $parms initial terminal halflife 0.2334598 1.6596428 slope 2.9690221 0.4176484 intercept 3.0022777 0.9685479 $conc [1] 2.31 1.44 1.03 0.84 0.64 0.42 0.24 0.17 0.13 0.10 0.09 2.31 1.44 1.03 0.84 [16] 0.64 0.42 0.24 0.17 0.13 0.10 0.09 2.31 1.44 1.03 0.84 0.64 0.42 0.24 0.17 [31] 0.13 0.10 0.09 2.31 1.44 1.03 0.84 0.64 0.42 0.24 0.17 0.13 0.10 0.09 2.31 [46] 1.44 1.03 0.84 0.64 0.42 0.24 0.17 0.13 0.10 0.09 2.31 1.44 1.03 0.84 0.64 [61] 0.42 0.24 0.17 0.13 0.10 0.09 $time [1] 0.25 0.50 0.75 1.00 1.25 2.00 3.00 4.00 5.00 6.00 8.00 0.25 0.50 0.75 1.00 [16] 1.25 2.00 3.00 4.00 5.00 6.00 8.00 0.25 0.50 0.75 1.00 1.25 2.00 3.00 4.00 [31] 5.00 6.00 8.00 0.25 0.50 0.75 1.00 1.25 2.00 3.00 4.00 5.00 6.00 8.00 0.25 [46] 0.50 0.75 1.00 1.25 2.00 3.00 4.00 5.00 6.00 8.00 0.25 0.50 0.75 1.00 1.25 [61] 2.00 3.00 4.00 5.00 6.00 8.00 $method [1] "biexp" attr(,"class") [1] "halflife" ------------------------------------------------------------ INDICES: 3 $parms initial terminal halflife 0.1204654 1.0466522 slope 5.7539100 0.6622517 intercept 5.4686132 1.6758661 $conc [1] 2.72 1.49 1.16 0.80 0.80 0.39 0.22 0.12 0.11 0.08 0.08 2.72 1.49 1.16 0.80 [16] 0.80 0.39 0.22 0.12 0.11 0.08 0.08 2.72 1.49 1.16 0.80 0.80 0.39 0.22 0.12 [31] 0.11 0.08 0.08 2.72 1.49 1.16 0.80 0.80 0.39 0.22 0.12 0.11 0.08 0.08 2.72 [46] 1.49 1.16 0.80 0.80 0.39 0.22 0.12 0.11 0.08 0.08 2.72 1.49 1.16 0.80 0.80 [61] 0.39 0.22 0.12 0.11 0.08 0.08 $time [1] 0.25 0.50 0.75 1.00 1.25 2.00 3.00 4.00 5.00 6.00 8.00 0.25 0.50 0.75 1.00 [16] 1.25 2.00 3.00 4.00 5.00 6.00 8.00 0.25 0.50 0.75 1.00 1.25 2.00 3.00 4.00 [31] 5.00 6.00 8.00 0.25 0.50 0.75 1.00 1.25 2.00 3.00 4.00 5.00 6.00 8.00 0.25 [46] 0.50 0.75 1.00 1.25 2.00 3.00 4.00 5.00 6.00 8.00 0.25 0.50 0.75 1.00 1.25 [61] 2.00 3.00 4.00 5.00 6.00 8.00 $method [1] "biexp" attr(,"class") [1] "halflife" > > > > > cleanEx(); ..nameEx <- "lee" > > ### * lee > > flush(stderr()); flush(stdout()) > > ### Name: lee > ### Title: Two-Phase Half-Life Estimation by Linear Fitting > ### Aliases: lee > ### Keywords: misc > > ### ** Examples > > > ## example for preparation 1 from Lee et. al (1990) > time <- c(0.5, 1.0, 4.0, 8.0, 12.0, 24.0) > conc <- c(75, 72, 61, 54, 36, 6) > result1 <- lee(conc=conc, time=time, method='ols', points=2) > print(result1$parms) initial terminal halflife 6.59747708 6.59747708 slope -0.04562805 -0.04562805 intercept 1.97385991 1.97385991 > plot(result1) > > ## example for preparation 2 from Lee et. al (1990) > time <- c(0.5, 1.0, 2.0, 6.5, 8.0, 12.5, 24.0) > conc <- c(75, 55, 48, 51, 39, 9, 5) > result2 <- lee(conc=conc, time=time, method='ols', points=2) > print(result2$parms) initial terminal halflife 5.94991193 5.94991193 slope -0.05059403 -0.05059403 intercept 1.85798384 1.85798384 > plot(result2) > > ## advanced plots > xlim <- c(0,30) > ylim <- c(1,80) > ylab <- 'Log Concentration' > text1 <- paste('Initial half-life:', round(result1$parms[1,1],3), ' Terminal half-life:', round(result1$parms[1,2],3)) > text2 <- paste('Initial half-life:', round(result2$parms[1,1],3), ' Terminal half-life:', round(result2$parms[1,2],3)) > split.screen(figs=c(2,1)) [1] 1 2 > screen(1) > plot(result1, ylab=ylab, main='Half-life: Preparation 1', xlim=xlim, ylim=ylim, log='y', sub=text1) > screen(2) > plot(result2, ylab=ylab, main='Half-life: Preparation 2', xlim=xlim, ylim=ylim, log='y', sub=text2) > close.screen(all=TRUE) > > > > ### *