# Module: ci_rvm.ci_rvm#

Classes:

 `CounterFun`(fun) Counts how often a function has been called `FlexibleSubproblem`(x, fun, jac, hess[, ...]) Class representing constained quadratic subproblems `Flipper`(index) Flips an array in a specified component

Functions:

 `find_CI`(x0, fun[, jac, hess, indices, ...]) Returns the profile likelihood confidence interval(s) for one or multiple parameters. `find_CI_bound`(x0, fun, index, direction[, ...]) Finds an end point of a profile likelihood confidence interval. `find_ci`(x0, fun[, jac, hess, indices, ...]) Returns the profile likelihood confidence interval(s) for one or multiple parameters. `find_ci_bound`(x0, fun, index, direction[, ...]) Finds an end point of a profile likelihood confidence interval. `find_function_CI`(x0, function, logL[, ...]) Returns the profile likelihood confidence interval(s) for a function of parameters. `find_function_ci`(x0, function, logL[, ...]) Returns the profile likelihood confidence interval(s) for a function of parameters. `get_independent_row_indices`(M[, jac, tol]) Returns a boolean array arr with arr[i]==True if and only if the i-th row of M is linearly independent of all other rows j with arr[j]==True. `is_negative_definite`(M[, tol]) Returns whether the given Matrix is negative definite.
class CounterFun(fun)[source]#

Bases: `object`

Counts how often a function has been called

class FlexibleSubproblem(x, fun, jac, hess, hessp=None, k_easy=0.1, k_hard=0.2)[source]#

Bases: `object`

Methods:

 `solve`(radius[, positiveDefinite, tol, jac0tol])
solve(radius, positiveDefinite=None, tol=1e-05, jac0tol=0, *args, **kwargs)[source]#
class Flipper(index: index in which the result should be flipped)[source]#

Bases: `object`

Flips an array in a specified component

find_CI(x0, fun, jac=None, hess=None, indices=None, directions=None, alpha=0.95, parallel=False, return_full_results=False, return_success=False, **kwargs)[source]#

Returns the profile likelihood confidence interval(s) for one or multiple parameters.

Parameters
• x0 (float[]) – Maximum likelihood estimate (MLE) of the paramters.

• fun (callable) – Log-likelihood function.

• jac (callable) – Gradient of `fun`. If None, it will be computed based on finite differences using numdifftools.

• hess (callable) – Hessian of `fun`. If None, it will be computed based on finite differences using numdifftools.

• indices (int[]) – Indices of the parameters of interest. If not given, all paramters will be considered.

• directions (float[][]) – Search directions. If not given, both end points of the confidence intervals will be determined. If given as a scalar, only lower end points will be returned if `directions<=0` and upper end points otherwise. If given as an array, the confidence interval end points specified in row `i` will be returned for parameter `i`. Entries `<=0` indicate that lower end points are desired, whereas positive entries will result in upper end points.

• alpha (float) – Desired confidence level. Must be in `(0,1)`

• parallel (bool) – If `True`, results will be computed in parallel using `multiprocessing.Pool`. Note that this requires that all arguments are pickable.

• return_full_results (bool) – If `True`, an `OptimizeResult` object will be returned for each confidence interval bound. Otherwise, only the confidence interval bounds for the parameters in question will be returned.

• return_success (bool) – If `True`, an array of the same shape as the result will be returned in addition, indicating for each confidence interval bound whether it was determined successfully.

• **kwargs (keyword arguments) – Other keyword arguments passed to `find_CI_bound()`. Look at the documentation there.

find_CI_bound(x0, fun, index, direction, jac=None, hess=None, alpha=0.95, fun0=None, jac0=None, hess0=None, customTarget=None, nmax=200, nchecks=65, apprxtol=0.5, resulttol=0.001, singtol=0.0001, minstep=1e-05, radiusFactor=1.5, infstep=10000000000.0, maxRadius=10000.0, disp=False, track_x=False, track_f=False)[source]#

Finds an end point of a profile likelihood confidence interval.

Parameters
• x0 (float[]) – Maximum likelihood estimate (MLE) of the paramters.

• fun (callable) – Log-likelihood function.

• index (int) – Index of the parameter of interest.

• direction (int or bool) – If `<=0`, the lower end point of the confidence interval is sought, else the upper end point is sought.

• jac (callable) – Gradient of `fun`. If None, it will be computed based on finite differences using numdifftools.

• hess (callable) – Hessian of `fun`. If None, it will be computed based on finite differences using numdifftools.

• alpha (float) – Desired confidence level. Must be in `(0,1)`

• fun0 (float) – log-likelihood at the MLE.

• jac0 (float[]) – Gradient of the log-liekelihood at the MLE.

• hess0 (float[][]) – Hessian of the log-likelihood at the MLE.

• customTarget (float) – Custom target log-likelihood l*. If this is given, `alpha` will be ignored.

• nmax (int) – Maximal number of iterations.

• nchecks (int) – Maximal number of trust-region changes per iteration.

• apprxtol (float) – Relative tolerance between `fun` and its approximation.

• resulttol (float) – Tolerance of the result (`fun` and `norm(jac)`).

• singtol (float) – Tolerance for singularity checks.

• minstep (int) – Controls the minimal radius of the trust region.

• radiusFactor (float) – Controls how quickly the trust region decreases. Must be in `[1, 2]`.

• infstep (float) – Stepsize after which a parameter is deemed unestimbale.

• maxRadius (float) – Rradius of the trust region in the last iteration.

• disp (bool) – Whether to print a status message in each iteration.

• track_x (bool) – Whether to return the parameter trace.

• track_f (bool) – Whether to return the log-likelihood trace.

find_ci(x0, fun, jac=None, hess=None, indices=None, directions=None, alpha=0.95, parallel=False, return_full_results=False, return_success=False, **kwargs)#

Returns the profile likelihood confidence interval(s) for one or multiple parameters.

Parameters
• x0 (float[]) – Maximum likelihood estimate (MLE) of the paramters.

• fun (callable) – Log-likelihood function.

• jac (callable) – Gradient of `fun`. If None, it will be computed based on finite differences using numdifftools.

• hess (callable) – Hessian of `fun`. If None, it will be computed based on finite differences using numdifftools.

• indices (int[]) – Indices of the parameters of interest. If not given, all paramters will be considered.

• directions (float[][]) – Search directions. If not given, both end points of the confidence intervals will be determined. If given as a scalar, only lower end points will be returned if `directions<=0` and upper end points otherwise. If given as an array, the confidence interval end points specified in row `i` will be returned for parameter `i`. Entries `<=0` indicate that lower end points are desired, whereas positive entries will result in upper end points.

• alpha (float) – Desired confidence level. Must be in `(0,1)`

• parallel (bool) – If `True`, results will be computed in parallel using `multiprocessing.Pool`. Note that this requires that all arguments are pickable.

• return_full_results (bool) – If `True`, an `OptimizeResult` object will be returned for each confidence interval bound. Otherwise, only the confidence interval bounds for the parameters in question will be returned.

• return_success (bool) – If `True`, an array of the same shape as the result will be returned in addition, indicating for each confidence interval bound whether it was determined successfully.

• **kwargs (keyword arguments) – Other keyword arguments passed to `find_CI_bound()`. Look at the documentation there.

find_ci_bound(x0, fun, index, direction, jac=None, hess=None, alpha=0.95, fun0=None, jac0=None, hess0=None, customTarget=None, nmax=200, nchecks=65, apprxtol=0.5, resulttol=0.001, singtol=0.0001, minstep=1e-05, radiusFactor=1.5, infstep=10000000000.0, maxRadius=10000.0, disp=False, track_x=False, track_f=False)#

Finds an end point of a profile likelihood confidence interval.

Parameters
• x0 (float[]) – Maximum likelihood estimate (MLE) of the paramters.

• fun (callable) – Log-likelihood function.

• index (int) – Index of the parameter of interest.

• direction (int or bool) – If `<=0`, the lower end point of the confidence interval is sought, else the upper end point is sought.

• jac (callable) – Gradient of `fun`. If None, it will be computed based on finite differences using numdifftools.

• hess (callable) – Hessian of `fun`. If None, it will be computed based on finite differences using numdifftools.

• alpha (float) – Desired confidence level. Must be in `(0,1)`

• fun0 (float) – log-likelihood at the MLE.

• jac0 (float[]) – Gradient of the log-liekelihood at the MLE.

• hess0 (float[][]) – Hessian of the log-likelihood at the MLE.

• customTarget (float) – Custom target log-likelihood l*. If this is given, `alpha` will be ignored.

• nmax (int) – Maximal number of iterations.

• nchecks (int) – Maximal number of trust-region changes per iteration.

• apprxtol (float) – Relative tolerance between `fun` and its approximation.

• resulttol (float) – Tolerance of the result (`fun` and `norm(jac)`).

• singtol (float) – Tolerance for singularity checks.

• minstep (int) – Controls the minimal radius of the trust region.

• radiusFactor (float) – Controls how quickly the trust region decreases. Must be in `[1, 2]`.

• infstep (float) – Stepsize after which a parameter is deemed unestimbale.

• maxRadius (float) – Rradius of the trust region in the last iteration.

• disp (bool) – Whether to print a status message in each iteration.

• track_x (bool) – Whether to return the parameter trace.

• track_f (bool) – Whether to return the log-likelihood trace.

find_function_CI(x0, function, logL, functionJac=None, functionHess=None, logLJac=None, logLHess=None, relativeError=0.0001, **kwargs)[source]#

Returns the profile likelihood confidence interval(s) for a function of parameters.

Parameters
• x0 (float[]) – Maximum likelihood estimate (MLE) of the paramters.

• function (callable) – Function of the parameters for which the confidence interval shall be computed

• logL (callable) – Log-likelihood function.

• functionJac (callable) – Gradient of `function`. If None, it will be computed based on finite differences using numdifftools.

• functionHess (callable) – Hessian of `function`. If None, it will be computed based on finite differences using numdifftools.

• logLJac (callable) – Gradient of `logL`. If None, it will be computed based on finite differences using numdifftools.

• logLHess (callable) – Hessian of `logL`. If None, it will be computed based on finite differences using numdifftools.

• relativeError (float) – Permitted relative error in the confidence interval bound.

• **kwargs (keyword arguments) – Other keyword arguments passed to `find_CI()` and `find_CI_bound()`. Look at the documentation there.

find_function_ci(x0, function, logL, functionJac=None, functionHess=None, logLJac=None, logLHess=None, relativeError=0.0001, **kwargs)#

Returns the profile likelihood confidence interval(s) for a function of parameters.

Parameters
• x0 (float[]) – Maximum likelihood estimate (MLE) of the paramters.

• function (callable) – Function of the parameters for which the confidence interval shall be computed

• logL (callable) – Log-likelihood function.

• functionJac (callable) – Gradient of `function`. If None, it will be computed based on finite differences using numdifftools.

• functionHess (callable) – Hessian of `function`. If None, it will be computed based on finite differences using numdifftools.

• logLJac (callable) – Gradient of `logL`. If None, it will be computed based on finite differences using numdifftools.

• logLHess (callable) – Hessian of `logL`. If None, it will be computed based on finite differences using numdifftools.

• relativeError (float) – Permitted relative error in the confidence interval bound.

• **kwargs (keyword arguments) – Other keyword arguments passed to `find_CI()` and `find_CI_bound()`. Look at the documentation there.

get_independent_row_indices(M: considered matrix, jac: ordering vector = None, tol: numerical tolerance = None) boolean array of linearly independent rows[source]#

Returns a boolean array arr with arr[i]==True if and only if the i-th row of M is linearly independent of all other rows j with arr[j]==True. The vector jac provides an ordering of the returned indices. If M[i] and M[j] are linearly dependent, then arr[i] will be True if jac[i] >= jac[j]. Otherwise, arr[i] will be False and arr[j] will be True.

is_negative_definite(M, tol=1e-05)[source]#

Returns whether the given Matrix is negative definite.

Uses a Cholesky decomposition.