I'm trying to run the following code in `R`, but I'm getting an error.

I'm not sure what part of the formula is incorrect. Any help would be greatly appreciated.

```
loglik<-function(y,theta)
{
  mu=theta[1]
  sigma2=theta[2]
  lambda=theta[3]
  n=length(y)
  -0.5*n*log(2*pi)-0.5*n*log(sigma2)-sum((y^lambda-1)/lambda-mu)^2/(2*sigma2)+(lambda-1)(sum(log(y)))
}

Error: attempt to apply non-function

```