likelihoodprofiler package¶
Submodules¶
likelihoodprofiler.get_endpoint module¶
-
likelihoodprofiler.get_endpoint.get_endpoint(theta_init, theta_num, loss_func, method, direction='right', loss_crit=0.0, scale=[], theta_bounds=[], scan_bound=None, scan_tol=0.001, loss_tol=0.001, local_alg=28, **kwargs)¶ Calculates right or left endpoint of CI for parameter component. It is a wripper of get_right_endpoint functions for selection of direction and using different transformations for faster optimization.
- Parameters
theta_init (Array[Float64]) – starting values of parameter vector \(\Theta\). The starting values is not necessary to be the optimum values for
loss_funcbut it the value ofloss_funcmust be lower thanloss_crit.theta_num (Int) – number \(n\) of vector component to compute confidence interval \(\Theta^n\).
loss_func (Function) – loss function \(\Lambda\left(\Theta\right)\) the profile of which is analyzed. Usually we use log-likelihood for profile analysis in form \(\Lambda( \theta ) = - 2 ln\left( L(\Theta) \right)\).
method (String) – computational method to evaluate interval endpoint. Currently the following methods are implemented:
"CICO_ONE_PASS","LIN_EXTRAPOL","QUADR_EXTRAPOL".direction (String) –
"right"or"left"endpoint to estimate.loss_crit (Float64) – critical level of loss function. The endpoint of CI for selected parameter is the value at which profile likelihood meets the value of
loss_crit.scale (String) – vector of scale transformations for each component. Possible values:
"direct", "log", "logit". This option can make optimization much more faster, especially for widetheta_bounds. The default value is"direct"(no transformation) for all components.theta_bounds (Array[Array[Float64,Float64]]) – vector of bounds for each component in format \((left_border, right_border)\). This bounds define the ranges for possible parameter values. The defaults are the non-limited values taking into account the
scale, i.e. \((0, Inf)\) for"log"scale.scan_bounds (Array[Float64,Float64]) – vector of scan bound for
theta_numcomponent. It must be within thetheta_boundsfor the scanned component. The defaults are (-9., 9.) for transformed values, i.e. :math:`(1e-9, 1e9) for"log"scale.scan_tol (Float64) – Absolute tolerance of scanned component (stop criterion).
loss_tol (Float64) – Absolute tolerance of
loss_funcatloss_crit(stop criterion). Restriction. Currently is not effective fornlopt.CICO_ONE_PASSmethods because of limitation innlopt.LN_AUGLAGinterface.local_alg (Function) – algorithm of optimization. Currently the local derivation free algorithms form NLOPT pack were tested. The methods:
nlopt.LN_NELDERMEAD, nlopt.LN_COBYLA, nlopt.LN_PRAXISshow good results. Methods:nlopt.LN_BOBYQA, nlopt.LN_SBPLX, nlopt.LN_NEWUOAis not recommended.**kwargs (Any) – the additional keyword arguments passed to
get_right_endpointfor specificmethod.
- Returns
object storing confidence endpoint and profile points found on fly.
- Return type
class EndPoint
likelihoodprofiler.get_interval module¶
-
class
likelihoodprofiler.get_interval.ParamInterval(input, loss_init, method, result)¶ Bases:
objectStructure storing result of parameter interval calculation
- Parameters
input (ParamIntervalInput) –
loss_init (Float64) –
method (String) –
-
plot()¶
-
class
likelihoodprofiler.get_interval.ParamIntervalInput(theta_init, theta_num, loss_func, loss_crit, scale, theta_bounds, scan_bounds, scan_tol, loss_tol, local_alg, fitter_options)¶ Bases:
objectCalculates right or left endpoint of CI for parameter component. It is a wripper of get_right_endpoint functions for selection of direction and using different transformations for faster optimization.
- Parameters
theta_init (Array[Float64]) – initial parameters vector
theta_num (Int) – number of the parameter for analysis
loss_func (Function) – loss function
loss_crit (Float64) – loss function maximum value, “identifiability level
scale (Array[String]) –
theta_bounds (Array[[Float64, Float64]]) – search bounds for id parameter
scan_bounds (Float64) –
scan_tol (Float64) – fitting tolerance for local optimizer (default - 1e-3)
loss_tol (Float64) – constraints tolerance
local_alg (Function) – local fitting algorithm (default - LN_NELDERMEAD)
fitter_options (Any) –
-
likelihoodprofiler.get_interval.get_interval(theta_init, theta_num, loss_func, method, loss_crit=0.0, scale=[], theta_bounds=[], scan_bounds=None, scan_tol=0.001, loss_tol=0.001, local_alg=28, **kwargs)¶ Computes confidence interval for single component theta_num of parameter vector and loss_func according to loss_crit level.
- Parameters
theta_init (Array[Float64]) – starting values of parameter vector \(\Theta\). The starting values is not necessary to be the optimum values for loss_func but it the value of
loss_funcmust be lower thanloss_crit.theta_num (Int) – number n of vector component to compute confidence interval \(\Theta^n\).
loss_func (Function) – loss function \(\Lambda\left(\theta\right)\) the profile of which is analyzed. Usually we use log-likelihood for profile analysis in form \(\Lambda( \theta ) = - 2 ln\left( L(\theta) \right)\).
method (String) – computational method to evaluate interval endpoint. Currently the following methods are implemented:
CICO_ONE_PASS,LIN_EXTRAPOL,QUADR_EXTRAPOL.loss_crit (Float64) – critical level of loss function. The endpoint of CI for selected parameter is the value at which profile likelihood meets the value of
loss_crit.scale (String) – vector of scale transformations for each component. Possible values:
"direct", "log", "logit". This option can make optimization much more faster, especially for widetheta_bounds. The default value is"direct"(no transformation) for all components.theta_bounds (Array[Array[Float64,Float64]]) – vector of bounds for each component in format \((left_border, right_border)\). This bounds define the ranges for possible parameter values. The defaults are the non-limited values taking into account the
scale, i.e. \((0, Inf)\) for"log"scale.scan_bounds (Array[Float64,Float64]) – vector of scan bound for
theta_numcomponent. It must be within thetheta_boundsfor the scanned component. The defaults are (-9., 9.) for transformed values, i.e. :math:`(1e-9, 1e9) for"log"scale.scan_tol (Float64) – Absolute tolerance of scanned component (stop criterion).
loss_tol (Float64) – Absolute tolerance of
loss_funcatloss_crit(stop criterion). Restriction. Currently is not effective fornlopt.CICO_ONE_PASSmethods because of limitation innlopt.LN_AUGLAGinterface.local_alg (Function) – algorithm of optimization. Currently the local derivation free algorithms form NLOPT pack were tested. The methods:
nlopt.LN_NELDERMEAD, nlopt.LN_COBYLA, nlopt.LN_PRAXISshow good results. Methods:nlopt.LN_BOBYQA, nlopt.LN_SBPLX, nlopt.LN_NEWUOAis not recommended.**kwargs (Any) – the additional keyword arguments passed to
get_right_endpointfor specificmethod.
- Returns
structure storing all input data and estimated confidence interval.
- Return type
likelihoodprofiler.get_right_endpoint module¶
-
likelihoodprofiler.get_right_endpoint.get_right_endpoint(theta_init, theta_num, loss_func, method='CICO_ONE_PASS', theta_bounds=[], scan_bound=9.0, scan_tol=0.001, loss_tol=None, scan_hini=1.0, scan_hmax=inf, local_alg=28, max_iter=100000, ftol_abs=0.001, **kwargs)¶ Interface for current and future methods for endpoint estimation.
- Parameters
theta_init (Array[Flaot64]) – theta_init: starting values of parameter vector \(\Theta\). The starting values is not necessary to be the optimum values for
loss_funcbut it the value ofloss_funcmust be lower thanloss_crit.theta_num (Int) – number \(n\) of vector component to compute confidence interval \(\Theta^n\).
loss_func (Function) – loss function the profile of which is analyzed, see
get_interval. In thisfunction losscrit is always equal 0 for code simplification.method (String) – this value is always fixed. Implemented methods are:
"CICO_ONE_PASS". It is implemented for easy switching between different implemented and future methods.theta_bounds (Array[Array[Float64, Float64]]) – vector of bounds for each component in format \((left_bound, right_bound)\). This bounds define the ranges for possible parameter values.
scan_bound (Float64) – right scan bound for
theta_numcomponent. It must be within thetheta_boundsfor the scanned component.scan_tol (Float64) – Absolute tolerance of scanned component (stop criterion).
loss_tol (Float64) – Absolute tolerance of
loss_funcatloss_crit(stop criterion). Restriction. Currently is not effective fornlopt.CICO_ONE_PASSmethods because of limitation innlopt.LN_AUGLAGinterface.local_alg (Function) – algorithm of optimization. Currently the local derivation free algorithms form NLOPT pack were tested. The methods:
nlopt.LN_NELDERMEAD, nlopt.LN_COBYLA, nlopt.LN_PRAXISshow good results. Methods:nlopt.LN_BOBYQA, nlopt.LN_SBPLX, nlopt.LN_NEWUOAis not recommended.**kwargs (Any) – the additional keyword arguments passed to
get_right_endpointfor specificmethod.
- Returns
Right end point value:
Float64.Profile points estimated on fly:
Array[ ProfilePoint, 1]Status of sulution:
String. One of values:"BORDER_FOUND_BY_SCAN_TOL","SCAN_BOUND_REACHED".
- Return type
Array
likelihoodprofiler.profile module¶
-
likelihoodprofiler.profile.profile(theta_init, theta_num, loss_func, skip_optim=False, theta_bounds=None, local_alg=28, ftol_abs=0.001, **kwargs)¶ Short summary.
- theta_initArray[Float64]
starting values of parameter vector \(\Theta\). The starting values is not necessary to be the optimum values for
loss_funcbut it the value ofloss_funcmust be lower thanloss_crit.- theta_numInt
number \(n\) of vector component to compute confidence interval \(\Theta^n\).
- loss_funcFunction
loss function \(\Lambda\left(\Theta\right)\) the profile of which is analyzed. Usually we use log-likelihood for profile analysis in form \(\Lambda( \theta ) = - 2 ln\left( L(\Theta) \right)\).
- skip_optimBool
set
Trueif you need marginal profile, i.e. profile without optimization. Default isFalse.- theta_bounds :Array[Array[Float64,Float64]]
vector of bounds for each component in format \((left_border, right_border)\). This bounds define the ranges for possible parameter values. The defaults are the non-limited values taking into account the
scale, i.e. \((0, Inf)\) for"log"scale.- local_algFunction
algorithm of optimization. Currently the local derivation free algorithms form NLOPT pack were tested. The methods:
nlopt.LN_NELDERMEAD, nlopt.LN_COBYLA, nlopt.LN_PRAXISshow good results. Methods:nlopt.LN_BOBYQA, nlopt.LN_SBPLX, nlopt.LN_NEWUOAis not recommended.- ftol_absFloat64
absolute tolerance criterion for profile function.
- **kwargsAny
the additional keyword arguments passed to
get_right_endpointfor specificmethod.
- Returns
Returns profile function for selected parameter component. Each call of the function starts optimization.
- Return type
Function
likelihoodprofiler.structures module¶
-
class
likelihoodprofiler.structures.EndPoint(value, profilePoints, status, direction, counter, supreme)¶ Bases:
objectStructure storing end point for confidence interval.
- Parameters
value (Float64 or None # value of endpoint or nothing) –
profilePoints (Array[ProfilePoint] # vector of profile points) –
status (String # result of analysis) –
direction (String # "right" or "left") –
counter (Int # number of loss_func() calls to calculate the endpoint) –
supreme (Float64 or None # maximal value inside profile interval) –
values - "BORDER_FOUND_BY_SCAN_TOL", "BORDER_FOUND_LOSS_TOL", (status) –
"MAX_ITER_STOP", "LOSS_ERROR_STOP" ("SCAN_BOUND_REACHED",) –
-
class
likelihoodprofiler.structures.ProfilePoint(value, loss, params, ret, counter)¶ Bases:
objectStructure storing one point from profile function.
- Parameters
value (Float64 # x value of profile point) –
loss (Float64 # y value of profile point (loss function at value)) –
params (Array[Float64] # vector of optimal values of loss_func arguments) –
ret (String # return value from NLOpt.optimize()) –
counter (Int # number of loss_func() calls to calculate the value) –
values - -5, 5, 3 (ret) –