I'm trying to follow how maximum likelihood works by using R. I'm following the example here but with some other data.
But I'm confused by the output. How is the MLE so different from what I'd expect which is 0.7 i.e. number of successes / total number of trials?
# MLE for Binomial Distribution y<-c(0,0,0,1,1,1,1,1,1,1) n<-length(y) # formulation for the log likelihood for the binomial logL <- function(p) sum(log(dbinom(y, n, p))) # again we can test the function for one value of p logL(0.8) #plot logL p.seq <- seq(0, 0.99, 0.01) plot(p.seq, sapply(p.seq, logL), type="l") #optimum: optimize(logL, lower=0, upper=1, maximum=TRUE)