I have a PDF of this where the t I got it from the inverse method. and the x from x<-rnorm(20,0,1). This is model from exponential parallel for survival analysis with covariate where I let lambda= b0+b1*x
PDF = 2 * (b0+b1*x) * exp(-(b0+b1*x)*t) * (1-exp(-(b0+b1*x)*t))
The problem is when I do maxLik function, the value for standard error in maxLik return NA values. I assign z1 as the log-likelihood function.
#Likelihood
library(maxLik)
LLF <- function(para){
set.seed(1)
b0 = para[1]
b1 = para[2]
#n = 1
z1 = (n*log(2)) + (n*log(b0+b1*xsum)) - ((b0+b1*xsum)*tsum) + (n*log(1-exp((-(b0 + b1*xsum)*tsum))))
return(z1)
}
mle <- maxLik(LLF, start = c(2,4))
summary(mle)
Maximum Likelihood estimation
Newton-Raphson maximisation, 3 iterations
Return code 1: gradient close to zero
Log-Likelihood: -22.7055
2 free parameters
Estimates:
Estimate Std. error t value Pr(> t)
[1,] 1.986 NA NA NA
[2,] 3.986 NA NA NA
Thank you in advance.
See return code 1: gradient close to zero. The std. errors are likely computed using the gradient/Hessian. If these are not proper then this could be the culprit.
Try running your function with the argument method='Nelder-Mead' and see if this alleviates the problem. If so, you can either use this method, or supply your own Jacobian and Hessian functions.