pysr3.lme.priors module

class pysr3.lme.priors.GaussianPriorLME(fe_params: Dict, re_params: Dict)

Bases: object

Implements Gaussian Prior for various models

Creates GaussianPrior

Parameters:
  • fe_params (dict[str: tuple(float, float)]) –

    gaussian prior parameters for fixed effects. The format is {“name”: (mean, std), …}

    E.g. {“intercept”: (0, 2), “time”: (1, 1)}

  • re_params (dict[str: tuple(float, float)]) – gaussian prior for variances of random effects. Same format as above.

forget()

Releases all problem-dependent quantities

Returns:

None

gradient_beta(beta, *args, **kwargs)

Evaluates the gradient of the prior with respect to the vector of fixed effects

Parameters:

beta (ndarray) – vector of fixed effects

Returns:

gradient w.r.t. beta

gradient_gamma(beta, gamma)

Evaluates the gradient of the prior with respect to the vector of random effects

Parameters:
  • beta (ndarray) – vector of fixed effects

  • gamma (ndarray) – vector of random effects

Returns:

gradient w.r.t. gamma

hessian_beta(beta, gamma)

Evaluates Hessian of the prior with respect to the vector of fixed effects

Parameters:
  • beta (ndarray) – vector of fixed effects

  • gamma (ndarray) – vector of random effects

Returns:

Hessian w.r.t. (beta, beta)

hessian_beta_gamma(beta, gamma)

Evaluates the mixed Hessian of the prior with respect to the vector of fixed and random effects

Parameters:
  • beta (ndarray) – vector of fixed effects

  • gamma (ndarray) – vector of random effects

Returns:

Hessian w.r.t. (beta, gamma)

hessian_gamma(beta, gamma)

Evaluates Hessian of the prior with respect to the vector of random effects

Parameters:
  • beta (ndarray) – vector of fixed effects

  • gamma (ndarray) – vector of random effects

Returns:

Hessian w.r.t. (gamma, gamma)

instantiate(problem: LMEProblem)

Instantiates a Gaussian prior with problem-dependent quantities

Parameters:

problem (LMEProblem) – problem to fit

Returns:

None

loss(beta, gamma)

Value of the prior at beta, gamma.

Parameters:
  • beta (ndarray) – vector of fixed effects

  • gamma (ndarray) – vector of random effects

Returns:

value of the prior.

class pysr3.lme.priors.NonInformativePriorLME

Bases: Prior

Implements a non-informative prior

Creates NonInformativePrior

forget()

Releases all problem-dependent values

Returns:

None

gradient_beta(beta, gamma)

Evaluates the gradient of the prior with respect to the vector of fixed effects

Parameters:
  • beta (ndarray) – vector of fixed effects

  • gamma (ndarray) – vector of random effects

Returns:

gradient w.r.t. beta

gradient_gamma(beta, gamma)

Evaluates the gradient of the prior with respect to the vector of random effects

Parameters:
  • beta (ndarray) – vector of fixed effects

  • gamma (ndarray) – vector of random effects

Returns:

gradient w.r.t. gamma

hessian_beta(beta, gamma)

Evaluates Hessian of the prior with respect to the vector of fixed effects

Parameters:
  • beta (ndarray) – vector of fixed effects

  • gamma (ndarray) – vector of random effects

Returns:

Hessian w.r.t. (beta, beta)

hessian_beta_gamma(beta, gamma)

Evaluates the mixed Hessian of the prior with respect to the vector of fixed and random effects

Parameters:
  • beta (ndarray) – vector of fixed effects

  • gamma (ndarray) – vector of random effects

Returns:

Hessian w.r.t. (beta, gamma)

hessian_gamma(beta, gamma)

Evaluates Hessian of the prior with respect to the vector of random effects

Parameters:
  • beta (ndarray) – vector of fixed effects

  • gamma (ndarray) – vector of random effects

Returns:

Hessian w.r.t. (gamma, gamma)

instantiate(problem)

Instantiates the prior based on the problem

Parameters:

problem (LMEProblem)

Returns:

None

loss(beta, gamma)

Value of the prior at beta, gamma.

Parameters:
  • beta (ndarray) – vector of fixed effects

  • gamma (ndarray) – vector of random effects

Returns:

value of the prior.