Class MaximumLikelihoodEstimation
- All Implemented Interfaces:
Serializable,Cloneable
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumIndicates which optimization method to use in maximizing the likelihood. -
Constructor Summary
ConstructorsConstructorDescriptionMaximumLikelihoodEstimation(double[] x, ProbabilityDistribution pd, double... guess) Constructor for maximum likelihood estimation -
Method Summary
Modifier and TypeMethodDescriptionvoidcompute()Computes the maximum likelihood estimates.voidComputes the maximum likelihood estimates with the specified optimization method.double[]Returns the parameter estimates.double[][]Returns the Hessian of the log-likelihood function evaluated at the current parameter estimates.doublegetLogLikelihood(double[] x, double... params) Returns the log-likelihood.doubleReturns minus the log-likelihood evaluated at the parameter estimates.double[]Returns the approximate standard errors of the maximum likelihood estimates.double[][]Returns the approximate variance-covariance matrix of the maximum likelihood estimates.voidsetClosedForm(boolean cf) Sets the flag indicating whether or not the closed form solution should be used.voidsetExact(boolean exact) Deprecated.voidsetGuess(double... guess) Sets the guess or starting values of the parameters.voidsetMaxIterations(int maxIterations) Sets the maximum number of iterations for the solver to use.final voidSets the random object to be used in the Nelder-Mead method.voidsetSample(double[] x) Sets the sample data to use in the estimation procedure.voidsetUseAnalytic(boolean useAnalytic) Sets the flag indicating whether or not the PDF supplies the analytic gradient and Hessian.
-
Constructor Details
-
MaximumLikelihoodEstimation
Constructor for maximum likelihood estimation- Parameters:
x- adoublearray containing the sample observationspd- an instance ofProbabilityDistributionguess- adoublearray or a comma-separated list of doubles giving the starting values for the parametersNote: The argument
guessis a variable length argument list (varargs).
-
-
Method Details
-
getLogLikelihood
public double getLogLikelihood(double[] x, double... params) Returns the log-likelihood.Note that this method is for convenience and does not use any of the member data or parameters. The user supplies the arguments.
- Parameters:
x- adoublearray containing sample dataparams- adoublearray or comma separated list of doubles containing the parameter values- Returns:
- a
double, the log-likelihood evaluated at the given data and parameter values
-
compute
public void compute() throws MinConNLP.ConstraintEvaluationException, MinConNLP.ObjectiveEvaluationException, MinConNLP.WorkingSetSingularException, MinConNLP.QPInfeasibleException, MinConNLP.PenaltyFunctionPointInfeasibleException, MinConNLP.LimitingAccuracyException, MinConNLP.TooManyIterationsException, MinConNLP.BadInitialGuessException, MinConNLP.IllConditionedException, MinConNLP.SingularException, MinConNLP.LinearlyDependentGradientsException, MinConNLP.NoAcceptableStepsizeException, MinConNLP.TerminationCriteriaNotSatisfiedExceptionComputes the maximum likelihood estimates.The method returns closed form solutions if
usedClosedFormis true and closed form solutions are available for the likelihood. Otherwise, the defaultOptimizationMethod.MINCONNLPis used to numerically find the estimates.- Throws:
MinConNLP.ConstraintEvaluationException- Constraint evaluation returns an error with current point.MinConNLP.ObjectiveEvaluationException- Objective evaluation returns an error with current point.MinConNLP.WorkingSetSingularException- Working set is singular in dual extended QP.MinConNLP.QPInfeasibleException- QP problem seemingly infeasible.MinConNLP.PenaltyFunctionPointInfeasibleException- Penalty function point infeasible.MinConNLP.LimitingAccuracyException- Limiting accuracy reached for a singular problem.MinConNLP.TooManyIterationsException- Maximum number of iterations exceeded.MinConNLP.BadInitialGuessException- Penalty function point infeasible for original problem. Try new initial guess.MinConNLP.IllConditionedException- Problem is singular or ill-conditioned.MinConNLP.SingularException- Problem is singular.MinConNLP.LinearlyDependentGradientsException- Working set gradients are linearly dependent.MinConNLP.NoAcceptableStepsizeException- No acceptable stepsize in [SIGMA,SIGLA].MinConNLP.TerminationCriteriaNotSatisfiedException- Termination criteria are not satisfied.
-
compute
public void compute(MaximumLikelihoodEstimation.OptimizationMethod optMethod) throws MinConNLP.ConstraintEvaluationException, MinConNLP.ObjectiveEvaluationException, MinConNLP.WorkingSetSingularException, MinConNLP.QPInfeasibleException, MinConNLP.PenaltyFunctionPointInfeasibleException, MinConNLP.LimitingAccuracyException, MinConNLP.TooManyIterationsException, MinConNLP.BadInitialGuessException, MinConNLP.IllConditionedException, MinConNLP.SingularException, MinConNLP.LinearlyDependentGradientsException, MinConNLP.NoAcceptableStepsizeException, MinConNLP.TerminationCriteriaNotSatisfiedException Computes the maximum likelihood estimates with the specified optimization method.The method returns closed form solutions if
usedClosedFormis true and closed form solutions are available for the likelihood.- Parameters:
optMethod- anOptimizationMethod- Throws:
MinConNLP.ConstraintEvaluationException- Constraint evaluation returns an error with current point.MinConNLP.ObjectiveEvaluationException- Objective evaluation returns an error with current point.MinConNLP.WorkingSetSingularException- Working set is singular in dual extended QP.MinConNLP.QPInfeasibleException- QP problem seemingly infeasible.MinConNLP.PenaltyFunctionPointInfeasibleException- Penalty function point infeasible.MinConNLP.LimitingAccuracyException- Limiting accuracy reached for a singular problem.MinConNLP.TooManyIterationsException- Maximum number of iterations exceeded.MinConNLP.BadInitialGuessException- Penalty function point infeasible for original problem. Try new initial guess.MinConNLP.IllConditionedException- Problem is singular or ill-conditioned.MinConNLP.SingularException- Problem is singular.MinConNLP.LinearlyDependentGradientsException- Working set gradients are linearly dependent.MinConNLP.NoAcceptableStepsizeException- No acceptable stepsize in [SIGMA,SIGLA].MinConNLP.TerminationCriteriaNotSatisfiedException- Termination criteria are not satisfied.
-
setUseAnalytic
public void setUseAnalytic(boolean useAnalytic) Sets the flag indicating whether or not the PDF supplies the analytic gradient and Hessian.- Parameters:
useAnalytic- aboolean. Whentrue, the method expects thepdfto supply the analytic gradient and Hessian calculation. Ifpdis an instance of classDiscreteUniformPD, then exclusively the analytical derivatives are used, that is,useAnalyticis always set totrue, and this method is ignored.Default:
useAnalytic=false.
-
setExact
public void setExact(boolean exact) Deprecated.usesetUseAnalytic(boolean)insteadSets the flag indicating whether or not the PDF supplies the exact gradient and Hessian.- Parameters:
exact- aboolean. Whentrue, the function expects thepdfto supply the analytic gradient and Hessian calculation. Ifpdis an instance of classDiscreteUniformPD, then exclusively the exact derivatives are used, that is,exactis always set totrue, and this method is ignored.Default:
exact=false.
-
setClosedForm
public void setClosedForm(boolean cf) Sets the flag indicating whether or not the closed form solution should be used.- Parameters:
cf- aboolean. When true, thecompute()method returns the closed form solution if theProbabilityDistributionis aClosedFormMaximumLikelihoodInterfaceobject. The option is ignored if that is not the case. Ifpdis an instance of classDiscreteUniformPD, then exclusively the closed form solution is computed, that is,cfis always set totrue, and this method is ignored.Default:
cf=false.
-
setGuess
public void setGuess(double... guess) Sets the guess or starting values of the parameters.- Parameters:
guess- adoublearray of the same length as the parameters containing proper starting values for the optimization.guessmay also be a comma separated list of doubles giving the parameter values.Note: The argument
guessis a variable length argument list (varargs).
-
setRandomObject
Sets the random object to be used in the Nelder-Mead method.- Parameters:
r- aRandomobject to be used in the computation of the complex vertices in the Nelder-Mead solver.Specifying a seed for the
Randomobject can produce repeatable/deterministic output.
-
setMaxIterations
public void setMaxIterations(int maxIterations) Sets the maximum number of iterations for the solver to use.- Parameters:
maxIterations- anint, the maximum number of iterations for the solver to use. The default ismaxIterations=400.
-
setSample
public void setSample(double[] x) Sets the sample data to use in the estimation procedure.- Parameters:
x- adoublearray containing sample observations of the random variable
-
getEstimates
public double[] getEstimates()Returns the parameter estimates.- Returns:
- a
doublearray containing the parameter estimates
-
getMinusLogLikelihood
public double getMinusLogLikelihood()Returns minus the log-likelihood evaluated at the parameter estimates.This method returns the value of the objective function, the minimum of minus the log-likelihood.
- Returns:
- a
double, minus the log-likelihood
-
getStandardErrors
Returns the approximate standard errors of the maximum likelihood estimates.- Returns:
- a
doublearray containing the standard errors - Throws:
SingularMatrixException- The matrix is singular.
-
getVarCov
Returns the approximate variance-covariance matrix of the maximum likelihood estimates. The approximation is the negative inverse Hessian of the log-likelihood.- Returns:
- a
doublematrix containing the approximate variance-covariance matrix - Throws:
SingularMatrixException- The matrix is singular.
-
getHessian
public double[][] getHessian()Returns the Hessian of the log-likelihood function evaluated at the current parameter estimates.- Returns:
- a
doublematrix containing the Hessian matrix
-
setUseAnalytic(boolean)instead