ModelFitResult¶
-
class
fitr.inference.modelfitresult.MCMCFitResult(method, nsubjects, nparams, name)¶ Results of model fitting with MCMC
Attributes
name (str) Model identifier. We suggest using free-parameters as identifiers method (str) Method employed in optimization. nsubjects (int) Number of subjects fitted. nparams (int) Number of free parameters in the fitted model. params (ndarray(shape=(nsubjects, nparams))) Array of parameter estimates paramnames (list) List of parameter names stanfit : Stan fit object summary (pandas.DataFrame) Summary of the MCMC fit results Methods
get_paramestimates(self, FUN=np.mean) Extracts parameter estimates trace_plot(self, figsize=None, save_figure=False, filename=’fitr-mcstan-traceplot.pdf’) Trace plot for fit results -
get_paramestimates(FUN=<Mock name='mock.median' id='139936813788240'>)¶ Extracts parameter estimates
Parameters: FUN : {numpy.mean, numpy.median}
-
make_summary()¶ Creates summary of Stan fitting results
-
trace_plot(figsize=None, save_figure=False, filename='fitr-mcstan-traceplot.pdf')¶ Easy wrapper for Stan Traceplot
Parameters: figsize : (optional) list [width in inches, height in inches]
Controls figure size
save_figure : bool
Whether to save the figure to disk
filename : str
The file name to be output
-
-
class
fitr.inference.modelfitresult.ModelFitResult(method, nsubjects, nparams, name=None)¶ Class representing the results of a fitrmodel fitting.
Attributes
name (str) Model identifier. We suggest using free-parameters as identifiers method (str) Method employed in optimization. nsubjects (int) Number of subjects fitted. nparams (int) Number of free parameters in the fitted model. params (ndarray(shape=(nsubjects, nparams))) Array of parameter estimates paramnames (list) List of parameter names Methods
set_paramnames(params) Sets names of RL parameters to the fitrfit object plot_ae(actual, save_figure=False, filename=’actual-estimate.pdf’) Plots estimated parameters against actual simulated parameters summary_table(write_csv=False, filename=’summary-table.csv’, delimiter=’,’) Writes a CSV file with summary statistics from the present model -
ae_metrics(actual, matches=None)¶ Computes metrics summarizing the ability of the model to fit data generated from a known model
Parameters: matches : list
List consisting of [rlparams object, column index in actual, column index in estimates]. Ensures comparisons are being made between the same parameters, particularly when the models have different numbers of free parameters.
Returns: DataFrame
Including summary statistics of the parameter matching
-
plot_ae(actual, save_figure=False, filename='actual-estimate.pdf')¶ Plots actual parameters (if provided) against estimates
Parameters: actual : ndarray(shape=(nsubjects, nparams))
Array of actual parameters from a simulation
save_figure : bool
Whether to save the figure to disk
filename : str
The file name to be output
-
set_paramnames(params)¶ Sets the names of the RL parameters to the fitrfit object
Parameters: params : list
List of parameters from the rlparams module
-
-
class
fitr.inference.modelfitresult.OptimizationFitResult(method, nsubjects, nparams, name)¶ Results of model fitting with optimization methods
Attributes
name (str) Model identifier. We suggest using free-parameters as identifiers method (str) Method employed in optimization. nsubjects (int) Number of subjects fitted. nparams (int) Number of free parameters in the fitted model. params (ndarray(shape=(nsubjects, nparams))) Array of parameter estimates paramnames (list) List of parameter names errs (ndarray(shape=(nsubjects, nparams))) Array of parameter estimate errors nlogpost (ndarray(shape=(nsubjects))) Subject level negative log-posterior probability nloglik (float) Subject level negative log-likelihood LME (float) Log-model evidence BIC (ndarray(shape=(nsubjects))) Subject-level Bayesian Information Criterion AIC (ndarray(shape=(nsubjects))) Subject-level Aikake Information Criterion summary (DataFrame) Summary of means and standard deviations for each free parameter, as well as negative log-likelihood, log-model-evidence, BIC, and AIC for the model Methods
plot_fit_ts(save_figure=False, filename=’fit-stats.pdf’) : Plots the evolution of log-likelihood, log-model-evidence, AIC, and BIC over optimization iterations param_hist(save_figure=False, filename=’param-hist.pdf’) : Plots hitograms of parameters in the model summary_table(write_csv=False, filename=’summary-table.csv’, delimiter=’,’) Writes a CSV file with summary statistics from the present model -
param_hist(save_figure=False, filename='param-hist.pdf')¶ Plots histograms of the parameter estimates
Parameters: save_figure : bool
Whether to save the figure to disk
filename : str
The file name to be output
-
plot_fit_ts(save_figure=False, filename='fit-stats.pdf')¶ Plots the log-model-evidence, BIC, and AIC over optimization iterations
Parameters: save_figure : bool
Whether to save the figure to disk
filename : str
The file name to be output
-
summary_table()¶ Generates a table summarizing the model-fitting results
-