I am programming a log likelihood function using the normal distribution (probit) for a binary independant variable. When using optim, I am getting an error :

$Error in optim(startvalues, probitll, gr = grad, Y = Ydoc, X = Xbiais, : initial value in 'vmmin' is not finite$

```
probitll<-function( par, X, Y){
Y<-as.matrix(Y)
X<-as.matrix(X)
K<-ncol(X)
b<-matrix(1:K, ncol = 1)
R<-as.vector(dnorm(X%*%b))
-sum(Y*log(R)+(1-Y)*log(1-R))
}
grad<-function(SV, X, Y){
X<-as.matrix(X)
Y<-as.matrix(Y)
K<-ncol(X)
b<-matrix(1:K, ncol = 1)
R<-as.vector(dnorm(X%*%b))
apply(R*X, 2, sum)
}
startvalues<-as.vector(modeltestMCO[,1])
resultprobit<-optim( startvalues, probitll, gr= grad, Y=Ydoc, X=Xbiais, method="BFGS", hessian=TRUE)
```