MLE_estimates <- optim(par=c(1,3,12,10), # Initial guess
fn=logLikelihood, # Likelihood function
lower = c(-Inf, -Inf, -Inf,-Inf), # Lower bound on parameters
upper = c(Inf, Inf, Inf,Inf), # Upper bound on parameters
hessian=TRUE, # Hessian for SEs
method = "L-BFGS-B", #CG,BFGS,SANN,bfgs
# Custom Inputs
y = data$y,delta = data$delta,x = data$x,
)
首先看optim的用法(官方给出的解释如下)
General-purpose Optimization
Description
General-purpose optimization based on Nelder–Mead, quasi-Newton and conjugate-gradient algorithms. It includes an option for box-constrained optimization and simulated annealing.
通用优化
描述
基于奈尔德-米德、拟牛顿和共轭梯度算法的通用优化。它