Majdi wrote:>
> The code that I am using is given by
>
> # compute the MLE for Normal(mu, var)
> #######################################
>
> U<-rnorm(10,mean=1, sd=2)
> Normal.lik<-function(theta, U){
> mu=theta[1]
> var=theta[2]
> n<-nrow(U)
> logl<- -0.5*n*log(var)-(sum((U-mu)**2))/(2*var)
> return(-logl)
> }
> optim(c(0,1),Normal.lik,U=U,method="BFGS"
>
>
U is not a matrix and therefore does not have rows.
Use n <- length(U).
Berend
--
View this message in context:
http://r.789695.n4.nabble.com/optim-tp3642204p3642254.html
Sent from the R help mailing list archive at Nabble.com.