Blog Archives

Transforming a Matrix in Parallel using RcppParallel

June 28, 2014
By
Transforming a Matrix in Parallel using RcppParallel

The RcppParallel package includes high level functions for doing parallel programming with Rcpp. For example, the parallelFor function can be used to convert the work of a standard serial “for” loop into a parallel one. This article describes using RcppParallel to transform an R matrix in parallel. Serial Version First a serial version of the matrix transformation. We take the square root of each...

Read more »

Summing a Vector in Parallel with RcppParallel

June 28, 2014
By
Summing a Vector in Parallel with RcppParallel

The RcppParallel package includes high level functions for doing parallel programming with Rcpp. For example, the parallelReduce function can be used aggreggate values from a set of inputs in parallel. This article describes using RcppParallel to sum an R vector. Serial Version First a serial version of computing the sum of a vector. For this we use a simple call to the STL std::accumulate function: #include...

Read more »

Speed Chain Ladder Analysis with Rcpp

June 23, 2014
By
Speed Chain Ladder Analysis with Rcpp

The Chain Ladder method is an actuarial technique used for projecting incurred insurance claims to their ultimate loss values. The data exists as claims triangles where the claims for each accounting year increments down the rows and the claims for eac...

Read more »

Speed Chain Ladder Analysis with Rcpp

June 23, 2014
By
Speed Chain Ladder Analysis with Rcpp

The Chain Ladder method is an actuarial technique used for projecting incurred insurance claims to their ultimate loss values. The data exists as claims triangles where the claims for each accounting year increments down the rows and the claims for eac...

Read more »

Call Python from R through Rcpp

April 5, 2014
By
Call Python from R through Rcpp

Introduction This post provides a brief introduction to calling Python from R through Rcpp. The official Python documentation explains how to embed python into C/C++ applications. Moreover, the Boost.Python library provides seamless interoperability between C++ and the Python programming language. Similarlly, Rcpp provides interoperability between C++ and R. Therefore, it is not hard to call Python from R through Rcpp and Boost.Python. Although there...

Read more »

Call Python from R through Rcpp

April 5, 2014
By
Call Python from R through Rcpp

Introduction This post provides a brief introduction to calling Python from R through Rcpp. The official Python documentation explains how to embed python into C/C++ applications. Moreover, the Boost.Python library provides seamless interoperability between C++ and the Python programming language. Similarlly, Rcpp provides interoperability between C++ and R. Therefore, it is not hard to call Python from R through Rcpp and Boost.Python. Although there...

Read more »

Using iterators for sparse vectors and matrices

March 31, 2014
By
Using iterators for sparse vectors and matrices

Iterating over a sparse vector Consider the following vector: idx1 <- c(2L, 0L, 4L, 0L, 7L) A sparse representation of this vector will tell that at entries 1,3,5 (or at entries 0,2,4 if we are 0-based) we will find the values 2,4,7. Using Eigen via RcppEigen we can obtain the coercion with .sparseView(). We can iterate over all elements (including the zeros) in a sparse vector...

Read more »

Using iterators for sparse vectors and matrices

March 31, 2014
By
Using iterators for sparse vectors and matrices

Iterating over a sparse vector Consider the following vector: idx1 <- c(2L, 0L, 4L, 0L, 7L)A sparse representation of this vector will tell that at entries 1,3,5 (or at entries 0,2,4 if we are 0-based) we will find the values 2,4,7. Using Eigen via RcppEigen we can obtain the coercion with .sparseView(). We can iterate over all elements (including the zeros) in a sparse vector...

Read more »

A simple array class with specialized linear algebra routines

March 20, 2014
By
A simple array class with specialized linear algebra routines

Currie, Durban and Eilers write: Data with an array structure are common in statistics, and the design or regression matrix for analysis of such data can often be written as a Kronecker product. Factorial designs, contingency tables and smoothing of data on multidimensional grids are three such general classes of data and models. In such a setting, we develop an arithmetic...

Read more »

Dynamic dispatch for sparse matrices

March 19, 2014
By
Dynamic dispatch for sparse matrices

We want to do matrix multiplication for 3 cases: dense times dense sparse times dense for sparse matrices of class dgCMatrix sparse times dense for sparse matrices of class indMatrix, using R’s Matrix package for sparse matrices in R and RcppArmadillo for C++ linear algebra: // ] #include <RcppArmadillo.h> using namespace Rcpp ; arma::mat matmult_sp(const arma::sp_mat X, const arma::mat Y){ ...

Read more »

Sponsors

Mango solutions



RStudio homepage



Zero Inflated Models and Generalized Linear Mixed Models with R

Quantide: statistical consulting and training



http://www.eoda.de









ODSC

CRC R books series













Contact us if you wish to help support R-bloggers, and place your banner here.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)