Rscript of the example in my thesis