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

posted by ElMaestro  – Denmark, 2013-07-24 00:35 (4350 d 11:17 ago) – Posting: # 11043
Views: 9,086

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,673 registered users;
66 visitors (0 registered, 66 guests [including 33 identified bots]).
Forum time: 11:52 CEST (Europe/Vienna)

Medical researches can be divided into two sorts:
those who think that meta is better and those
who believe that pooling is fooling.    Stephen Senn

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