Apologies for the lengthy code.
I tried a simple (and shorter) piece of code (pasted below) and it still
gives me the same error for last few rows. Is this a bug or am I doing
something totally wrong?  Could anyone please provide some help/pointers ?

PS.  beta0 was fixed to 0.001 in the previous code. Also if I manually
estimated the integral isnt 0. If I scramble the row order, it is again
only the last few rows that dont integrate.
Thanks
data1<-expand.grid(1:5,0:6,10)
names(data1)<-c("ID","TIME", "DOSE")
data1<-data1[order(data1$DOSE,data1$ID,data1$TIME),]
ed<-data1[!duplicated(data1$ID) , c(1,3)]
ed$base=1
ed$drop=1
set.seed(5234123)
k<-0
for (i in 1:length(ed$ID))
{
k<-k+1
ed$base[k]<-100*exp(rnorm(1,0,0.2))
ed$drop[k]<-0.20*exp(rnorm(1,0,0.5))
}
comb1<-merge(data1[, c("ID","TIME")], ed)

comb1$disprog<-comb1$base*exp(-comb1$drop*comb1$TIME)
comb1$integral=0
hz.func1<-function(t,bshz,beta1, change)
{ ifelse(t==0,bshz, bshz*exp(beta1*change)) }
q<-0
for (m in i:length(comb1$ID))
{
q<-q+1
comb1$integral[q]<-integrate(hz.func1, lower=0, upper=comb1$TIME[q],
          bshz=0.001,beta1=0.035,
         change=comb1$disprog[q])$value
}
comb1

        [[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.

Reply via email to