TTT flawed in case of a lagtime… [🇷 for BE/BA]

posted by ElMaestro  – Denmark, 2013-07-24 00:35 (4348 d 16:52 ago) – Posting: # 11043
Views: 9,080

Hi Helmut,

❝ Does anybody have a clever idea how I can find the lagtime in R without a loop? Essentially I would search backwards from tmax until I find the first NA.


Not thoroughly tested, but if I get your drift, then here's something to consider:
time=c(1,2,3,4,5,6,7,8,9,10)
conc=c(NA,NA,NA,5,19,56, 53,46,40, NA)
data=data.frame(time, conc)

d1=subset(data, !(is.na(conc))) ##d1 now holds everything not NA
Tmax=subset(d1,  conc==max(d1[,2]))[1,1] ##records Tmax
d4=subset(data, (is.na(conc)) &(time<Tmax) ) ##takes all NA's observed until Tmax
Tlag=(subset(data, (is.na(conc))&&(time<Tmax)))[nrow(d4),1] ##Time of last observed NA before Tmax


Not thoroughly tested though :PCchaos:

Pass or fail!
ElMaestro

Complete thread:

UA Flag
Activity
 Admin contact
23,424 posts in 4,927 threads, 1,677 registered users;
32 visitors (0 registered, 32 guests [including 8 identified bots]).
Forum time: 17:27 CEST (Europe/Vienna)

Philosophy, like medicine, has plenty of drugs, few good remedies,
and hardly any specific cures.    Sebastien-Roch Nicolas de Chamfort

The Bioequivalence and Bioavailability Forum is hosted by
BEBAC Ing. Helmut Schütz
HTML5