diff --git a/.nojekyll b/.nojekyll index b6f4951..4dd38eb 100644 --- a/.nojekyll +++ b/.nojekyll @@ -1 +1 @@ -2e7347ed \ No newline at end of file +7bab3c81 \ No newline at end of file diff --git a/1_introduction.html b/1_introduction.html index 5871718..e8c972e 100644 --- a/1_introduction.html +++ b/1_introduction.html @@ -2,7 +2,7 @@ - + @@ -203,7 +203,7 @@ diff --git a/2_predictors.html b/2_predictors.html index d0a0ea8..cb7483f 100644 --- a/2_predictors.html +++ b/2_predictors.html @@ -2,7 +2,7 @@ - + @@ -21,44 +21,10 @@ margin: 0 0.8em 0.2em -1em; /* quarto-specific, see https://github.com/quarto-dev/quarto-cli/issues/4556 */ vertical-align: middle; } -/* CSS for syntax highlighting */ -pre > code.sourceCode { white-space: pre; position: relative; } -pre > code.sourceCode > span { line-height: 1.25; } -pre > code.sourceCode > span:empty { height: 1.2em; } -.sourceCode { overflow: visible; } -code.sourceCode > span { color: inherit; text-decoration: inherit; } -div.sourceCode { margin: 1em 0; } -pre.sourceCode { margin: 0; } -@media screen { -div.sourceCode { overflow: auto; } -} -@media print { -pre > code.sourceCode { white-space: pre-wrap; } -pre > code.sourceCode > span { display: inline-block; text-indent: -5em; padding-left: 5em; } -} -pre.numberSource code - { counter-reset: source-line 0; } -pre.numberSource code > span - { position: relative; left: -4em; counter-increment: source-line; } -pre.numberSource code > span > a:first-child::before - { content: counter(source-line); - position: relative; left: -1em; text-align: right; vertical-align: baseline; - border: none; display: inline-block; - -webkit-touch-callout: none; -webkit-user-select: none; - -khtml-user-select: none; -moz-user-select: none; - -ms-user-select: none; user-select: none; - padding: 0 4px; width: 4em; - } -pre.numberSource { margin-left: 3em; padding-left: 4px; } -div.sourceCode - { } -@media screen { -pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; } -} - + @@ -104,9 +70,6 @@ "search-label": "Search" } } - - - @@ -206,7 +169,7 @@ @@ -258,7 +221,10 @@

Table of contents

@@ -313,9 +276,9 @@

Table of contents

-
+
-

4  Binary Data

+

4  Binary Data and Choices

@@ -337,178 +300,30 @@

4  4.1 The Data

For this chapter, we will be using the data from Wagenmakers et al. (2008) - Experiment 1 (also reanalyzed by Heathcote and Love 2012), that contains responses and response times for several participants in two conditions (where instructions emphasized either speed or accuracy). Using the same procedure as the authors, we excluded all trials with uninterpretable response time, i.e., responses that are too fast (<180 ms) or too slow (>2 sec instead of >3 sec, see Thériault et al. 2024 for a discussion on outlier removal).

In this chapter, we will focus on the “amount” of errors between the two conditions (response times will be the focus of the next chapter).

-
-
using Downloads, CSV, DataFrames, Random
-using Turing, Distributions, StatsFuns, SequentialSamplingModels
-using GLMakie
-
-Random.seed!(123)  # For reproducibility
-
-df = CSV.read(Downloads.download("https://raw.githubusercontent.com/DominiqueMakowski/CognitiveModels/main/data/wagenmakers2008.csv"), DataFrame)
-
-# Show 10 first rows
-first(df, 10)
-
-
10×5 DataFrame
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
RowParticipantConditionRTErrorFrequency
Int64String15Float64BoolString15
11Speed0.7falseLow
21Speed0.392trueVery Low
31Speed0.46falseVery Low
41Speed0.455falseVery Low
51Speed0.505trueLow
61Speed0.773falseHigh
71Speed0.39falseHigh
81Speed0.587trueLow
91Speed0.603falseLow
101Speed0.435falseHigh
-
-
-
+
#| code-fold: false
+
+using Downloads, CSV, DataFrames, Random
+using Turing, Distributions, StatsFuns, SequentialSamplingModels
+using GLMakie
+
+Random.seed!(123)  # For reproducibility
+
+df = CSV.read(Downloads.download("https://raw.githubusercontent.com/DominiqueMakowski/CognitiveModels/main/data/wagenmakers2008.csv"), DataFrame)
+
+# Show 10 first rows
+first(df, 10)

Let us first compute the average number of errors for each condition.

-
-
combine(groupby(df, :Condition), :Error => mean)
-
-
2×2 DataFrame
- - - - - - - - - - - - - - - - - - - - - - - - - -
RowConditionError_mean
String15Float64
1Speed0.110407
2Accuracy0.0451463
-
-
-
-
-
-Code -
dat = combine(groupby(df, :Condition), :Error => mean)
-
-fig = Figure()
-ax = Axis(fig[1, 1], ylabel="Average error rate", xticks =([0, 1], ["Speed", "Accuracy"]))
-barplot!(ax, [0], [dat.Error_mean[1]], label="Speed", color=:red)
-barplot!(ax, [1], [dat.Error_mean[2]], label="Accuracy", color=:green)
-axislegend()
-fig
-
-
-
┌ Warning: Found `resolution` in the theme when creating a `Scene`. The `resolution` keyword for `Scene`s and `Figure`s has been deprecated. Use `Figure(; size = ...` or `Scene(; size = ...)` instead, which better reflects that this is a unitless size and not a pixel resolution. The key could also come from `set_theme!` calls or related theming functions.
-└ @ Makie C:\Users\domma\.julia\packages\Makie\VRavR\src\scenes.jl:220
-
-
- -
-
+
#| code-fold: false
+
+combine(groupby(df, :Condition), :Error => mean)
+
dat = combine(groupby(df, :Condition), :Error => mean)
+
+fig = Figure()
+ax = Axis(fig[1, 1], ylabel="Average error rate", xticks =([0, 1], ["Speed", "Accuracy"]))
+barplot!(ax, [0], [dat.Error_mean[1]], label="Speed", color=:red)
+barplot!(ax, [1], [dat.Error_mean[2]], label="Accuracy", color=:green)
+axislegend()
+fig

4.2 Logistic models for Binary Data

@@ -518,6 +333,122 @@

\(0.11\) for the intercept (close to the true value) and then decides to explore a value of \(-0.20\). This would lead to a tentative value of \(0.11 - 0.20 = -0.09\)… but this parameter is impossible (the p parameter of the \(Bernouilli\) distribution must be betwen 0 and 1).

Similarly to the previous chapter, we will avoid these issues by expressing our probability p on the log scale. This way, the effect of Accuracy will be expressed as a log-odds (i.e., the log of the odds ratio), which can take any value between \(-\infty\) and \(+\infty\). We will then convert this log-odds back to a probability using the logistic function which maps any value to the [0, 1] range.

+ +