Skip to content

Commit

Permalink
Update tutorial03_modelfitting.ipynb
Browse files Browse the repository at this point in the history
  • Loading branch information
shawnrhoads committed Oct 22, 2024
1 parent f841a3c commit f070570
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions tutorials/tutorial03_modelfitting.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -862,17 +862,17 @@
"<hr width=50%>\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$."
]
},
{
Expand Down Expand Up @@ -1816,6 +1816,32 @@
"\n",
"<img src=\"https://scontent-lga3-2.xx.fbcdn.net/v/t1.6435-9/192874660_277375547403284_6812776080155347208_n.jpg?_nc_cat=104&ccb=1-7&_nc_sid=833d8c&_nc_ohc=s36tGXlN9K0Q7kNvgFjXWxl&_nc_ht=scontent-lga3-2.xx&_nc_gid=Ak4lXPQCYscPZaeBhCFR9rS&oh=00_AYCJkIg9XMtjRHATQQz0Mp_nxxHSzDsGzvD9KdOwYV-rDQ&oe=673E4A9B\" alt=\"meme-all-models-are-wrong\" style=\"width: 25%;\">\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": {
Expand Down

0 comments on commit f070570

Please sign in to comment.