Here are the R codes I used in my STAT692 (Data Analysis using R) class