public class MaximumLikelihoodEstimation extends Object implements Serializable, Cloneable
Modifier and Type | Class and Description |
---|---|
static class |
MaximumLikelihoodEstimation.OptimizationMethod
Indicates which optimization method to use in maximizing the likelihood.
|
Constructor and Description |
---|
MaximumLikelihoodEstimation(double[] x,
ProbabilityDistribution pd,
double... guess)
Constructor for maximum likelihood estimation
|
Modifier and Type | Method and Description |
---|---|
void |
compute()
Computes the maximum likelihood estimates.
|
void |
compute(MaximumLikelihoodEstimation.OptimizationMethod optMethod)
Computes the maximum likelihood estimates with the specified optimization
method.
|
double[] |
getEstimates()
Returns the parameter estimates.
|
double[][] |
getHessian()
Returns the Hessian of the log-likelihood function evaluated at the
current parameter estimates.
|
double |
getLogLikelihood(double[] x,
double... params)
Returns the log-likelihood.
|
double |
getMinusLogLikelihood()
Returns minus the log-likelihood evaluated at the parameter estimates.
|
double[] |
getStandardErrors()
Returns the approximate standard errors of the maximum likelihood
estimates.
|
double[][] |
getVarCov()
Returns the approximate variance-covariance matrix of the maximum
likelihood estimates.
|
void |
setClosedForm(boolean cf)
Sets the flag indicating whether or not the closed form solution should
be used.
|
void |
setExact(boolean exact)
Deprecated.
|
void |
setGuess(double... guess)
Sets the guess or starting values of the parameters.
|
void |
setMaxIterations(int maxIterations)
Sets the maximum number of iterations for the solver to use.
|
void |
setRandomObject(Random r)
Sets the random object to be used in the Nelder-Mead method.
|
void |
setSample(double[] x)
Sets the sample data to use in the estimation procedure.
|
void |
setUseAnalytic(boolean useAnalytic)
Sets the flag indicating whether or not the PDF supplies the analytic
gradient and Hessian.
|
public MaximumLikelihoodEstimation(double[] x, ProbabilityDistribution pd, double... guess)
x
- a double
array containing the sample observationspd
- an instance of ProbabilityDistribution
guess
- a double
array or a comma-separated list of
doubles giving the starting values for the parameters
Note: The argument guess
is a variable length argument list
(varargs).
public double getLogLikelihood(double[] x, double... params)
Note that this method is for convenience and does not use any of the member data or parameters. The user supplies the arguments.
x
- a double
array containing sample dataparams
- a double
array or comma separated list of
doubles containing the parameter valuesdouble
, the log-likelihood evaluated at the given
data and parameter valuespublic 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.TerminationCriteriaNotSatisfiedException
The method returns closed form
solutions if usedClosedForm
is true and closed form solutions are
available for the likelihood. Otherwise,
the default OptimizationMethod.MINCONNLP
is used to numerically find the estimates.
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.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
The method returns closed form solutions if usedClosedForm
is true and closed form solutions are
available for the likelihood.
optMethod
- an OptimizationMethod
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.public void setUseAnalytic(boolean useAnalytic)
useAnalytic
- a boolean
. When true
, the function
expects the pdf
to supply the analytic gradient and Hessian
calculation.
Default: useAnalytic
= false
.
public void setExact(boolean exact)
MaximumLikelihoodEstimation.setUseAnalytic(boolean)
insteadexact
- a boolean
. When true
, the function
expects the pdf
to supply the analytic gradient and Hessian
calculation.
Default: exact
= false
.
public void setClosedForm(boolean cf)
cf
- a boolean
. When true, the MaximumLikelihoodEstimation.compute()
method returns the closed form solution if the
ProbabilityDistribution
is a
ClosedFormMaximumLikelihoodInterface
object. The option is
ignored if that is not the case.
Default: cf
= false
.
public void setGuess(double... guess)
guess
- a double
array of the same length as the
parameters containing proper starting values for the optimization.
guess
may also be a comma separated list of doubles giving
the parameter values.
Note: The argument guess
is a variable length argument list
(varargs).
public final void setRandomObject(Random r)
r
- a Random
object to be used in the computation
of the complex vertices in the Nelder-Mead solver.
Specifying a seed for the Random
object can produce
repeatable/deterministic output.
public void setMaxIterations(int maxIterations)
maxIterations
- an int
, the maximum number of iterations for
the solver to use. The default is maxIterations=400
.public void setSample(double[] x)
x
- a double
array containing sample observations of
the random variablepublic double[] getEstimates()
double
array containing the parameter estimatespublic double getMinusLogLikelihood()
This method returns the value of the objective function, the minimum of minus the log-likelihood.
double
, minus the log-likelihoodpublic double[] getStandardErrors() throws SingularMatrixException
double
array containing the standard errorsSingularMatrixException
- The matrix is singular.public double[][] getVarCov() throws SingularMatrixException
double
matrix containing the approximate
variance-covariance matrixSingularMatrixException
- The matrix is singular.public double[][] getHessian()
double
matrix containing the Hessian matrixCopyright © 2020 Rogue Wave Software. All rights reserved.