search for: cmhz

Displaying 1 result from an estimated 1 matches for "cmhz".

Did you mean: cmh
2012 Apr 08
1
Avoid loop with the integrate function
...ed$frac[k]<-0.5*exp(rnorm(1,0,0.1)) } comb1<-merge(data1[, c("ID","TIME")], ed) comb2<-comb1 comb2$score<-comb2$base*exp(-comb2$drop*comb2$TIME) func1<-function(t,cov1,beta1, change,other) { ifelse(t==0,cov1, cov1*exp(beta1*change+other)) } comb3<-comb2 comb3$cmhz=0 comb3<-comb3[order(comb3$ID, comb3$TIME), ] for (q in 1:length(comb3$ID)) { comb3$cmhz[q]<-integrate(func1, lower=0, upper=comb3$TIME[q], cov1=0.001,beta1=0.02, change=comb3$score[q], other=comb3$frac[q])$value } head(comb3) [[alternative HTML version deleted]]