Dear Oscar, The problem has to do with rounding (because you set the global digits value to 2). Although what you see is 2.4*270=670; when R actually calculates it, it is using full precision. If you set
options(digits=7) # the default you will see that AR=2.357362, not 2.4. HTH, Joshua On Sun, May 2, 2010 at 4:48 PM, oscar linares <wins...@gmail.com> wrote: > Dear Rxperts, > > Running the following code: > ======================================================= > twlo=10; twhi=20; wt=154; vd=0.5; cl=0.046; tau=6; t=3; F=1; > > wtkg <- wt/2.2 # convert lbs to kg > > vd.pt <- wtkg * vd # compute weight-based vd (L) > cl.pt <- wtkg * cl # compute CL (L/hr) > k <- cl.pt/vd.pt # compute k (hr^-1) > > cave <- round((twhi - twlo)/log(twhi/twlo),2) > doserate <- (cl.pt * cave)/F > > # maintenance dose (Dm) > total_dose_tau <- round(doserate * tau,0) > > Cmax <- total_dose_tau/vd.pt > Cmin <- Cmax * exp(-k * tau) > > AR <- 1/(1 - exp(-k * tau)) > > Cmaxss <- Cmax * AR > Cminss <- Cmin * AR > Cfluctss <- (Cmaxss - Cminss) > Ct <- (Cmaxss * exp(-k * t)) > > dose_loading_vd <- round(Cmaxss * vd.pt,0) > dose_loading_dm <- round(total_dose_tau * AR,0) > > options(digits=2) > > c("Ther. Win. (mg)"=twlo,"to"=twhi,"Wt (kg)"=wtkg,"Vd (L)"=vd.pt,"CL > (L/hr)"=cl.pt,"Cave (mg)"=cave,"D/tau (mg/hr)"=doserate,"tau > (hr)"=tau,"Total Dose (mg)"=total_dose_tau,"Cmax (mg)"=Cmax,"Cmin > (mg)"=Cmin,"AR"=AR,"Cmaxss (mg/L)"=Cmaxss,"Cminss (mg/L)"=Cminss,"Cfluct > (mg/L)"=Cfluctss,"C(t) (mg/L)"=Ct,"DL wVd (mg)"=dose_loading_vd,"DL wDm > (mg)"=dose_loading_dm) > =========================================================================== > Gives > Ther. Win. (mg) to Wt (kg) Vd (L) CL > (L/hr) Cave (mg) > 10.0 20.0 70.0 35.0 > 3.2 14.4 > D/tau (mg/hr) tau (hr) Total Dose (mg) Cmax (mg) Cmin > (mg) AR > 46.5 6.0 279.0 8.0 > 4.6 2.4 > Cmaxss (mg/L) Cminss (mg/L) Cfluct (mg/L) C(t) (mg/L) DL wVd > (mg) DL wDm (mg) > 18.8 10.8 8.0 14.3 > 658.0 658.0 > > But, there is an error from R? > > AR * total_dose_tau = 658 but that is wrong > > Total Dose (mg) = 279 * AR (=2.4) = 670 > > Please help. I don't want to harm anyone. A difference of 12 mg of a highly > toxic drug can at the very least cause significant harm. > > > -- > Oscar > Oscar A. Linares, MD > Translational Medicine Unit > La Plaisance Bay, Bolles Harbor > Monroe, Michigan 48161 > > Department of Medicine, > University of Toledo College of Medicine > Toledo, OH 43606-3390 > > Department of Internal Medicine, > The Detroit Medical Center (DMC) > Harper University Hospital > Wayne State University School of Medicine > Detroit, Michigan 48201 > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Joshua Wiley Senior in Psychology University of California, Riverside http://www.joshuawiley.com/ ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.