Reputation: 1
I try to run MLE, and get the
Error in if (!all(lower[isfixed] <= fixed[isfixed] & fixed[isfixed] <= :
missing value where TRUE/FALSE needed constantly,
The negative likelihood function
likelihood.normal <- function (mu,sigma,y ){
pdf_yt <- dnorm(y, mu, sigma, log= FALSE)
-sum(log(pdf_yt))
}
The MLE command
library(stats4)
est.normal<-c(est$mean, est$sd)
bound.lower <-est.normal*0.5 # set the lower bound for the method "L-BFGS-B"
bound.upper <-est.normal*2.0 # set the upper bound for the method "L-BFGS-B"
est.mle<-mle(minuslogl =likelihood.normal, start= list(mu = est$mean, sigma = est$sd),method="L-BFGS-B",fixed = list(y= return.log), lower=bound.lower, upper= bound.upper)
If the fixed parameter is removed, the issue is gone. But I need the fixed parameter.
Upvotes: 0
Views: 510
Reputation: 1
Had this same issue. Changing "fixed =" to "data =" and using mle2 from the bbmle package solved it for me.
Upvotes: 0
Reputation: 163
I too came across this error, and I believe it to be due to package dependency issues within the stats4::mle package.
When I submitted the project, I took a functional approach instead. Create a function that generates a function of the parameters with the data already preset as in the following:
logLikelihood.Norm.Function <- function (y) {
logLikelihood.ParamFunc <- function (mu, sigma) {
n <- length(y)
pdf_yt <- dnorm(y, mu, sigma, log = FALSE)
log.likelihood.value <- -sum(log(pdf_yt))
return(log.likelihood.value)
}
return(logLikelihood.ParamFunc)
}
Upvotes: 0