R : Computing maximum likelihood estimator

I want to compute maximum likelihood estimator of mean,mu, of normal distribution with variance=36.

But the following procedure showing error:

set.seed(36)

x <- rnorm(50,mean=20,sd=6)

loglikelikelihood<- function(mu,x){
 L = (-50)*log(sqrt(2*pi)*6)-((1/72)*(sum(x^2)-2*mu*sum(x)+50*mu^2))
 }

optimize(f=loglik,X=x,interval=c(0,100),maximum=T)

Answers


you misspelled two arguments. Try writing loglikelihood instead of loglik and x instead of X, it'll work.

> optimize(f=loglikelihood,x=x,interval=c(0,100),maximum=T)
$maximum
[1] 20.86679

$objective
[1] -157.6814

Need Your Help

CodeIgniter/PHP - Calling a view from within a view

php codeigniter views

Basically for my webapp I'm trying to organise it a bit better. As it at the moment, every time I want to load a page, I have to do it from my controller like so:

Setting uniform <input type="file"> width in all browsers

html css cross-browser

What combination of CSS or attributes are needed?