I am using R to do some multivariate analysis. For this work I need to integrate the trivariate PDF. While doing this I got the error:
Error in integrate(Vectorize(function(x) { :
evaluation of function gave a result of wrong length
As you could see, vectorize is not the solution so something wrong is going on.
If somebody can give me a hint about what is going on, I'll really appreciate it.
Here is my code:
library(mvtnorm)
f1<-function(x, y, z) {dmvnorm(x=as.matrix(cbind(x,y,z)), mean=mu.t, sigma)} #PDF with all three
#integrate out x
integrate(Vectorize(function(x) {f1(x=c1, y=c2, z=c3)}), 0.1,0.5, rel.tol=1.5e-20)$value