title: Initial value in 'vmmin' is not finite even when changing the starting value
body: <p>I am trying to do maximum likelihood for a spatio-temporal model. However,  I think I should start with a simple model first before I go for the complicated one. I tried to run a simple maximum likelihood model and it gave me this error message: <code>initial value in 'vmmin' is not finite</code>. I was looking at another post, and it suggested I change the starting value. I did try a couple of different values, and it still gave me this error message. What should I do? is there anything wrong with the function? </p>
  
  <pre><code>y &lt;- matrix(low$SalePrice, ncol=1)    
  z &lt;- as.matrix(cbind(1,low$Housesqft,low$lotacres))    
  OLS&lt;-function(theta,y,z){    
     n &lt;- nrow(z)    
     k &lt;- ncol(z)    
     beta &lt;- theta[1:k]    
     sigma2 &lt;- theta[k+1]    
     e &lt;- y-z%*%beta    
     logl&lt;- -0.5*n*log(2*pi)-0.5*n*log(sigma2)-((t(e)%*%e)/(2*sigma2))    
     return(-logl)    
  }    
  p &lt;- optim(c(1,1,1),OLS, method="BFGS", hessian=TRUE, y=y, z=z)
  Error in optim(c(1, 1, 1), OLS, method = "BFGS", hessian = TRUE,
    y = y, z = z) : 
    initial value in 'vmmin' is not finite
  </code></pre>