Empirical Priors¶
-
class
fitr.inference.empiricalpriors.
EmpiricalPriors
(loglik_func, params, name='EmpiricalPriorsModel')¶ Inference procedure with empirical priors
Attributes: - name : str
Name of the model being fit. We suggest using the free parameters.
- loglik_func : function
The log-likelihood function to be used for model fitting
- params : list
List of parameters from the rlparams module
- nparams : int
Number of free parameters in the model
- param_rng : list
List of strings denoting the parameter ranges (see rlparams module for further details)
Methods
fit(data, n_iterations=1000, opt_algorithm=’BFGS’) Runs model-fitting algorithm logposterior(x, states, actions, rewards) Computes the log-poseterior probability __printfitstart(self, n_iterations, algorithm, verbose) (Private) function to print optimization info to console __printupdate(self, opt_iter, subject_i, posterior_ll, verbose) (Private) function to print iteration info to console -
fit
(data, n_iterations=1000, c_limit=0.001, opt_algorithm='L-BFGS-B', verbose=True)¶ Runs the maximum a posterior model-fitting with empirical priors.
Parameters: - data : dict
Dictionary of data from all subjects.
- n_iterations : int
Maximum number of iterations to allow.
- c_limit : float
Threshold at which convergence is determined
- opt_algorithm : {‘L-BFGS-B’}
Algorithm to use for optimization. Only works at present with L-BFGS-B.
- verbose : bool
Whether to print progress of model fitting
Returns: - ModelFitResult
Representation of the model fitting results
-
logposterior
(x, states, actions, rewards)¶ Represents the log-posterior probability function
Parameters: - x : ndarray(nparams)
Array of parameters for single subject
- states : ndarray
Array of states encountered by subject. Number of rows should reflect number of trials. If the task is a multi-step per trial task, then the number of columns should reflect the number of steps, unless a custom likelihood function is used which does not require this.
- actions: ndarray
Array of actions taken by subject. Number of rows should reflect number of trials. If the task is a multi-step per trial task, then the number of columns should reflect the number of steps, unless a custom likelihood function is used which does not require this.
- rewards : ndarray
Array of rewards received by the subject. Number of rows should reflect number of trials. If there are multiple steps at which rewards are received, they should be stored in different columns, unless a custom likelihood funciton is used which does not require this.
Returns: - float
Log-posterior probability