I want to write an R-code to compute the MLEs of (µ; σ2; λ) try initial values λ = 0.5、.... 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.
library(stats4)
obs.loglik4 = function(y,theta)
{
mu=theta[1]
sig2=theta[2]
lambda = theta[3]
n = length(y)
loglik = -0.5*n*log(2*pi)-0.5*n*log(sig2)-
sum(((y^lambda-1)/lambda-mu)^2)/(2*sig2)+(lambda-1)*sum(log(y))
return(loglik)
}
mle.4=mle(minuslogl=obs.loglik4,start=c(1,1,0.5))
##Error in mle(minuslogl = obs.loglik4, start = c(1, 1, 0.5)) :
Mismatch in length of start values
mle.4=mle(minuslogl=obs.loglik4,start=list(mu=mean(y),sig2=var(y),lambda=0.5))
##Error in l2v(start) :
some named values are not arguments to the supplied log-likelihood