R/hbrr.integrate3.R

Defines functions `hbrr.integrate3`

`hbrr.integrate3` <-
function(MU,V,A=c(1,1,1),...){
    hb.z<-function(z){
        hb.yZ<-function(y,Z){
            ny<-length(y)
            outy<-rep(NA,ny)
            hb.xYZ<-function(x,Y,Z){
                q<-matrix(c(x,rep(Y,length(x)),rep(Z,length(x))),ncol=3)
                outx<-(1/(1+10^(A[1]*x)))*
                      (1/(1+10^(A[2]*Y)))*
                      (1/(1+10^(A[3]*Z)))*
                      dmvnorm(q,mean=MU,sigma=V)
                return(outx)
            }
            for (j in 1:ny){
                ### integrate over x keeping y and z fixed
                outy[j]<-integrate(hb.xYZ,-Inf,Inf,Y=y[j],Z=Z,...)$value
            }
            outy
       }
       nz<-length(z)
       outz<-rep(NA,nz)
       for (k in 1:nz){
           outz[k]<-integrate(hb.yZ,-Inf,Inf,Z=z[k],...)$value
       }
       return(outz)
    }
    out<-integrate(hb.z,-Inf,Inf,...)$value
    return(out)
}

Try the hbim package in your browser

Any scripts or data that you put into this service are public.

hbim documentation built on Aug. 24, 2023, 5:10 p.m.