From f0705709fb8354a46b0c9cc8a162240fdb4405e2 Mon Sep 17 00:00:00 2001 From: Shawn Rhoads Date: Tue, 22 Oct 2024 08:29:11 -0400 Subject: [PATCH] Update tutorial03_modelfitting.ipynb --- tutorials/tutorial03_modelfitting.ipynb | 32 ++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/tutorials/tutorial03_modelfitting.ipynb b/tutorials/tutorial03_modelfitting.ipynb index 65532db..eb617c6 100644 --- a/tutorials/tutorial03_modelfitting.ipynb +++ b/tutorials/tutorial03_modelfitting.ipynb @@ -862,17 +862,17 @@ "
\n", "\n", "### Estimating Parameters with MLE\n", - "Now we can try to accurately estimate the free parameters: $\\alpha$, $\\beta$, and $\\gamma$ that best explain a set of observed state transitions and rewards. Similar to the linear regression example, we will use both **grid search** and **`scipy.optimize.minimize`** to find the parameter values that maximize the likelihood of the observed data.\n", + "Now we can try to accurately estimate the free parameters: $\\alpha$ and $\\beta$ that best explain a set of observed state transitions and rewards. Similar to the linear regression example, we will use both **grid search** and **`scipy.optimize.minimize`** to find the parameter values that maximize the likelihood of the observed data.\n", "\n", "The likelihood of the observed data depends on both the value updates and the action choices made by the agent. We will use the **negative log-likelihood** as the objective function to minimize.\n", "\n", "The negative log-likelihood function for the TD Learning model can be expressed as:\n", "\n", "$$\n", - "-\\log \\mathcal{L}(\\beta, \\alpha, \\gamma) = -\\sum_{t=1}^{T} \\log P(A_t | S_t, \\beta, \\alpha, \\gamma)\n", + "-\\log \\mathcal{L}(\\beta, \\alpha, \\gamma) = -\\sum_{t=1}^{T} \\log P(A_t | S_t, \\beta, \\alpha)\n", "$$\n", "\n", - "where $P(A_t | S_t, \\beta, \\alpha, \\gamma)$ is the probability of selecting action $A_t$ given state $S_t$ and the model parameters $\\beta, \\alpha, \\gamma$." + "where $P(A_t | S_t, \\beta, \\alpha)$ is the probability of selecting action $A_t$ given state $S_t$ and the model parameters $\\beta, \\alpha$." ] }, { @@ -1816,6 +1816,32 @@ "\n", "\"meme-all-models-are-wrong\"\n" ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Model Comparison\n", + "\n", + "When fitting models to data, it is essential to use model comparison to evaluate the relative fit of different models. Common approaches to model comparison include (but are not limited to):\n", + "- **Akaike Information Criterion (AIC)**: A measure that balances model fit and complexity, with lower AIC values indicating better models.\n", + "- **Bayesian Information Criterion (BIC)**: Similar to AIC but penalizes model complexity more strongly, often leading to more simpler models.\n", + "- **Log Model Evidence (LME)**: A Bayesian approach that computes the log evidence of the model given the data, allowing for direct comparison of models.\n", + "- **WAIC (Widely Applicable Information Criterion)**: A Bayesian approach that estimates the out-of-sample predictive accuracy of the model, considering both fit and complexity.\n", + "- **Cross-Validation**: A technique that assesses how well a model generalizes to new data by splitting the data into training and testing sets." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Additional Resources\n", + "\n", + "- Wilson, R. C., & Collins, A. G. (2019). Ten simple rules for the computational modeling of behavioral data. eLife, 8, e49547. doi: 10.7554/eLife.49547 https://elifesciences.org/articles/49547 \n", + "- Daw, N. D. (2011). Trial-by-trial data analysis using computational models. Decision making, affect, and learning: Attention and performance XXIII, 23(1). doi: 10.1093/acprof:oso/9780199600434.003.0001 https://www.princeton.edu/~ndaw/d10.pdf \n", + "- Rhoads, S. A. (2023). pyEM: Expectation Maximization with MAP estimation in Python. doi: 10.5281/zenodo.10415396 https://github.com/shawnrhoads/pyEM\n", + "- Rhoads, S. A. & Gan, L. (2022). Computational models of human social behavior and neuroscience: An open educational course and Jupyter Book to advance computational training. Journal of Open Source Education, 5(47), 146. doi: 10.21105/jose.00146 https://shawnrhoads.github.io/gu-psyc-347/ " + ] } ], "metadata": {