Note that likelihood_model is not a class, but a concept, that other likelihood models implement. They should add likelihood_model to their class definition, and then they can use this function to compute the MLE.

# S3 method for likelihood_model
fit(object, ...)

Arguments

object

The likelihood_model object

...

Additional arguments to pass into the likelihood model's loglik, score, and hess_loglik constructors.

Value

An MLE solver (function) that returns an MLE object and accepts as arguments:

  • df: The data frame

  • par: The initial guess for the parameters

  • control: Control parameters for the optimization algorithm

  • ...: Additional arguments to pass into the likelihood model's constructed functions from loglik, score, and hess_loglik.

Details

This function uses the optim function to find the MLE of the parameters of a likelihood model. It uses the loglik and score methods to compute the log-likelihood and score function, respectively.

There are a few interesting options for the control argument:

  • method: The optimization method to use. The default is Nelder-Mead, which is a derivative-free method. Other options like include BFGS are gradient-based methods, which may be preferable if you provide a score function (rather than using the default finite-difference). There is also the SANN method, which is a simulated annealing method. This method is useful for multimodal likelihood functions, where the MLE may be sensitive to the initial guess. The SANN method is a more global method, but it is slower and may require some tweaking. Regardless, if you do use SANN, you should follow it up with a local search method like Nelder-Mead to refine the solution.