// **********************************************************// // Calculate mu matrix // // **********************************************************// // [[Rcpp::export]] arma::mat mu_cpp (arma::cube Y, arma::rowvec eta) { int D = Y.n_rows; int A = Y.n_cols; int Q = Y.n_slices; arma::mat mu = arma::zeros(D, A); for (unsigned int d = 0; d < D; d++) { for (unsigned int a = 0; a < A; a++) { arma::vec Y_da = Y.subcube(d, a, 0, d, a, Q-1); mu(d, a) = sum(eta * Y_da); } } return mu; }
// **********************************************************// // Calculate lambda list // // **********************************************************// // [[Rcpp::export]] arma::mat lambda_cpp (arma::cube X_d, arma::rowvec beta) { int A = X_d.n_rows; int P = X_d.n_slices; arma::mat lambda_d = arma::zeros(A, A); for (unsigned int a = 0; a < A; a++) { for (unsigned int r = 0; r < A; r++) { if (r != a) { arma::vec X_dar = X_d.subcube(a, r, 0, a, r, P-1); lambda_d(a,r) = sum(beta * X_dar); } } } return lambda_d; }
// armadillo subcube testing // [[Rcpp::export]] arma::cube subCube(arma::cube cubeDat, int first_row, int first_col, int first_slice, int last_row, int last_col, int last_slice){ return(cubeDat.subcube(first_row, first_col, first_slice, last_row, last_col, last_slice)); }