[R] numerical integration problem

przeszczepan przeszczepan at o2.pl
Thu Jun 29 13:23:55 CEST 2006


Hi,

I have got problems integrating the following function using "integrate": 

lambdat<-function(t){
tempT<-T[k,][!is.na(T[k,])]#available values from k-th row of matrix T
tempJ<-J[k,][!is.na(J[k,])]

hg<-length(tempT[tempT<=t & tempJ==0])#counts observations satisfing the conditions
ag<-length(tempT[tempT<=t & tempJ==1])

lambdaXY[hg+1,ag+1]#takes  values from a 10x10 matrix
}

I keep receiving this message:

1: longer object length
        is not a multiple of shorter object length in: tempT <= t 
2: longer object length
        is not a multiple of shorter object length in: tempT <= t & tempJ == 0 

What I suspect is that the "integrate" function submits the whole vector of points at which the integral is to be evaluated at once. For my function to be integrated it would rather have to be evaluated at each point after another in a loop of some kind.

Can you think of a way to solve this problem without me having to write the integrating procedure from scratch (I have no idea about FORTRAN and this is what the "integrate" description refers to)?

Thank you.

Kind Regards,
Lukasz Szczepanski
Student



More information about the R-help mailing list