Learn R Programming

CARrampsOcl (version 0.1.4)

oclCombo1col3: Function to call OpenCL to calculate posterior means and standard deviations of random effects in models with 2 structure matrices.

Description

Function to call OpenCL to calculate posterior means and standard deviations of random effects in models with 2 structure matrices.

Usage

oclCombo1col3(a, b, b2, D, tausqy, tausqphi, By)

Arguments

a
Eigenvector matrix of 1st Q matrix.
b
Eigenvector matrix of 2nd Q matrix.
b2
Eigenvector matrix of 3rd Q matrix.
D
Matrix of eigenvalues from the 2 structure matrices.
tausqy
Vector of samples of measurement error precision.
tausqphi
Matrix sampled values of spatial precisions.
By
Vector resulting from premultiplication of data vector y b transpose of kronecker sum of eigenvector matrices.

Value

  • phimeanVector of means of posterior densities of random effects
  • phisdVector of standard deviations of marginal posterior

Examples

Run this code
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (a, b, b2, D, tausqy, tausqphi, By) 
{
    if (!is.numeric(a) | !is.numeric(b) | !is.numeric(b2)) 
        stop("a, b, and b2 must be numeric matrices")
    na1 <- nrow(a)
    nb1 <- nrow(b)
    nb21 <- nrow(b2)
    nc1 <- length(tausqy)
    F1 <- ncol(tausqphi) + 1
    nab <- na1 * nb1 * nb21
    mresults <- rep(0, 2 * nab)
    out <- .C("oclCombo1col3", a = as.double(as.vector(t(a))), 
        b = as.double(as.vector(t(b))), b2 = as.double(as.vector(t(b2))), 
        D = as.double(as.vector(t(D))), tausqy = as.double(tausqy), 
        tausqphi = as.double(as.vector(t(tausqphi))), By = as.double(By), 
        results = as.double(mresults), na1 = as.integer(na1), 
        nb1 = as.integer(nb1), nb21 = as.integer(nb21), nc1 = as.integer(nc1), 
        F1 = as.integer(F1))
    return(list(phimean = out$results[1:nab], phisd = sqrt(out$results[(nab + 
        1):(2 * nab)]/(nc1 - 1))))
  }

Run the code above in your browser using DataLab