Dear members,

I'm getting an error with the "integrate" function. Searching in the r-help
archives, I think this may have something to do with the function (it is not
returning a vector but a number), but I don't see exactly what.

The function to integrate was defined with a for loop first:

    for (i in 1:(nbcol-1))
    {tdon1<-tdon[,i]
    tdon11<-subset(tdon1,tdon1!="NA")
    fctk1<-function(x)
    {density(tdon11, bandwidth=h[i], kernel="gaussian")$y}

    for (j in (i+1):nbcol)
    {tdon2<-tdon[,j]
    tdon21<-subset(tdon2,tdon2!="NA")
    fctk2<-function(x)
    {density(tdon21,bandwidth=h[j],kernel="gaussian")$y}

    diffctk<-function(x)
    {abs(fctk1(x)-fctk2(x))}
    }}

    integrate(diffctk,-Inf,Inf,subdivisions=100)$integral ,

    where:
    h <- 1.06*ect*(nlc^-0.2); ect <- apply (data,2,sd); nlc <-length of each
column in data, excluding NA's.

The result gives the error:

    "Error in integrate (diffctk, -Inf, Inf, subdivisions = 100) :
        evaluation of function gave a result of wrong length"

Is the any way finding these error? I would be happy to be enlightened.

With kind regards,

Rogério

	[[alternative HTML version deleted]]

