maximum likelihood estimation in r code