# Fitting multievent capture-recapture models with Rcpp

I started with the excellent Rcpp chapter in the Advanced R book by Hadley Wickham which I complemented with the various vignettes that come with the package. As always, I googled the problems I had and often ended up finding the solution on stackoverflow. The rcpp-devel discussion list is the place where questions should be asked about Rcpp.

My objective was to implement the likelihood of a relatively simple multievent capture-recapture model ( Pradel 2005) with Rcpp. I recycled some R code I had and a dataset on shearwaters I used in a paper ( Gimenez et al. 2012).

The R code is available on my GitHub here. To run it, you just need to type Rcpp::sourceCpp(‘multi event.cpp’) in the console. I’m convinced that the code can be improved, but this simple exercise showed that minimizing the deviance coded with Rcpp and calculating the Hessian was 10 times faster than using the deviance coded in standard R.

Next steps will be to go for RcppArmadillo for matrix computations and RcppNumerical for optimisation (and numerical integration for random effects).

Hope this is useful.

**Update:** Following an advice from Romain Francois and Dirk Eddelbuettel (the Rcpp gurus), I have switched to
RcppArmadillo to rely on the code developed by professionals and decades of testing. Now the RcppArmadillo code is 50 times faster than basic R! The code is available on
my GitHub.