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(index, target, x0, fun, jac, hess)

Finds an end point of a profile likelihood confidence interval.

find_profile_CI_bound(index, direction, x0, …)

Finds the profile likelihood confidence interval for a parameter.

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

Class representing constained quadratic subproblems

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, hess, 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.

  • hess (callable) – Hessian of fun.

  • 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(index, target, x0, fun, jac, hess, forward=True, fun0=None, jac0=None, hess0=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
  • index (int) – Index of the parameter of interest.

  • target (float) – Target log-likelihood l* (typically a quantile of the chi-sqared distribution).

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

  • fun (callable) – Log-likelihood function.

  • jac (callable) – Gradient of fun.

  • hess (callable) – Hessian of fun.

  • forward (bool) – True, if right end point of the confidence interval is sought, else False.

  • 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.

  • 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_profile_CI_bound(index, direction, x0, fun, jac, hess, alpha=0.95, fun0=None, *args, **kwargs)[source]

Finds the profile likelihood confidence interval for a parameter.

Warning

DEPRECATED! Use find_CI() instead!

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

  • direction (int) – If -1, we search for the left end point of the confidence interval; if 1, we search for the right end point of the confidence interval

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

  • fun (callable) – Log-likelihood function.

  • jac (callable) – Gradient of fun.

  • hess (callable) – Hessian of fun.

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

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.