Skip to content

curvefit.initializer.initializer.PriorInitializer

A prior initializer for a parameter set

For a given solver, model and parameter set there are a number of strategies to get information to inform a prior for a later model fit. A PriorInitializer uses one or more PriorInitializerComponents to inform what priors should be for a new parameter set. Typically, the data passed to PriorInitializer is only a subset of the data, for example a subset that has a substantial number of data points that result in well-informed parameter estimates for all parameters in a model. The updated parameter set that results from PriorInitializer.initialize() has priors that are informed by whatever PriorInitializerComponents were passed in.

These PriorInitializerComponents are model-specification-specific. You need to be aware of what component you are passing in and that it matches your model_prototype. If it does not, an error will be thrown. The requirements are listed in the description sections of each PriorInitializerComponent.

Arguments

  • self.prior_initializer_components (List[PriorInitializerComponent]) a list of prior initializer components (instantiated) to use in updating the parameter set

Attributes

  • self.component_types (List[str]): list of the types of initializer components
  • self.joint_solver (curvefit.solvers.solver.Solver): a solver/model run on all of the data
  • `self.individual_solvers (List[curvefit.solvers.solver.Solver]): a list of solver/models run on each group in the data individually

Methods

initialize

For a given data, model prototype and solver prototype, run the prior initialization for all prior initializer components and return an updated parameter set.

  • data (curvefit.core.data.Data): a Data object that represents all of the data that will be used in the initialization (this will often be a subset of all available data)
  • model_prototype (curvefit.core.model.CoreModel): a model that will be used as the prototype and cloned for the joint and individual fits
  • `solver_prototype (curvefit.solvers.solver.Solver): a solver that will be used as the prototype and cloned for the joint and individual fits

Usage

prior_initializer = PriorInitializer([LnAlphaBetaPrior(), BetaPrior()])
new_parameter_set = prior_initializer.initialize(
    data=data, model_prototype=model_prototype,
    solver_prototype=solver_prototype, parameter_set_prototype
)