All the R codes for the thesis