postCP change point detection with GSOC

GSoC - postCP

 

Introduction to postCP

The project aimed at improving the postCP package and making it available on CRAN again. The snag that prevented the package from being updated is the recent requirement that in the R code, .C() calls require DUP=TRUE arguments, and .Call() is suggested instead of .C(). The implementation of postCP package required that it’s done in the most R compliant way. Separating out the model specific implementation and the core implementation. The core part is implemented in C++ for speed in calculations. The project page can be found here.

Implementation

To improve the usability and user friendliness, a glm syntax based “formula” and “family” specification was added. These commits are in the feature-glmsyntax branch. Also the model specific implementation was done by adding four models. (Gaussian, Poisson, Binomial and Gamma). The previous package only included three models. (Gaussian, Poisson and Binomial).  These commits are found here.
The model specific part was integrated with the core specific part (C++ forward backward algorithm) to give the required results. Also following the change point model, a separate section was added for parameter calculations and parameter updates based on the updated log evidences. Standard error checks were included to handle incorrect user inputs as much as possible and to give meaningful error messages. Vignettes have been included to provide long form documentation. The commits are found here.
The development has been completed as agreed in the project proposal. All the branches have been merged to the master branch and it reflects the latest package.
The completed source code of the package has been included in the following public Google folder for viewing.

Run time analysis 

The following table represents a run time analysis of postCP package done on a 2.7 GHz machine with 4GB RAM running on Ubuntu 14.04. It shows a linear time complexity; O(N) 
 

 

CPU TIME ( Time in seconds )
n (iterations ) Mean Model Slope Model
1000 0.104 0.056
10000 0.536 0.628
100000 2.636 2.3
1000000 16.076 13.776

 

The mean model and the slope model are given below.

 

Building the Package

 
2. Navigate into the postCP folder

3. Build using R / RStudio. ( If it’s RStudio use Ctrl + Shift + B )

Coding Guidelines 

 I referred to “Hadley Wickam R style” and “R style. An Rchaeological Commentary” for appropriate coding style guidelines because I saw that there are some issues with existing R packages because of not following best practices.

Final remarks 

I would like to thank my mentors Gregory Nuel and Guillem Regaill for all the support and guidance and also bearing with me for the duration of the project. 😀 I would also like to thank Minh Luong (original creator of the package) for the  additional documentation provide while I was trying to understand the previous implementation.

Finally thank you for GSOC for the great learning opportunity! 😀

The official GSoC Project page can be found here.

Linked Blog posts

The following blog post explains my GSOC experience and the challenges that I had to face as a summary.
http://138.197.9.17/index.php/2016/08/22/my-experience-with-gsoc-and-r/

Leave a Reply