R script for plotting BIC curve