xx<-c(0.7012873,0.2661434,0.5750884,0.1432547,0.1929323,0.4916651,0.7922205,0.4219847,0.1840799,0.3095818) ######## # Plotting Beta Likelihood ###### BetaL<-function(a,b,x) { n<-length(x) exp(-n*log(beta(a,b))+(a-1)*sum(log(x))+(b-1)*sum(log(1-x))) } a<-seq(0.01,5,length=100) b<-seq(0.01,8,length=100) Z<-outer(a,b,BetaL,xx) persp(a,b,Z,theta=45,phi=45,ticktype="detailed",xlab=expression(alpha),ylab=expression(beta),zlab="Likelihood") ######################### # Beta MLE using nlm() ##### beta.mlen<- function(xx,a0,b0) { negLL<-function(p,x) { a<-p[1] b<-p[2] n<-length(x) n*log(beta(a,b))-(a-1)*sum(log(x))-(b-1)*sum(log(1-x)) } nlm(negLL, p = c(a0, b0), hessian = T, x = xx) } beta.mlen(xx,0.1,0.1)