-
Notifications
You must be signed in to change notification settings - Fork 2
/
LDT_accuracy.qmd
73 lines (55 loc) · 1.55 KB
/
LDT_accuracy.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
---
engine: julia
---
# Analysis of accuracy in the LDT
The lexical decision task (LDT) for the English Lexicon Project recorded the response time and the accuracy of the response.
Here we analyze the accuracy of the response with a generalized linear mixed model.
Attach the packages to be used
```{julia}
#| code-fold: true
#| output: false
using CairoMakie
CairoMakie.activate!(; type="svg")
using DataFrames
using EmbraceUncertainty: dataset
using MixedModels
using MixedModelsMakie
using StandardizedPredictors
```
and define some constants
```{julia}
#| code-fold: true
#| output: false
@isdefined(contrasts) || const contrasts = Dict{Symbol, Any}()
@isdefined(progress) || const progress = false
```
## Create the dataset
```{julia}
#| output: false
trials = innerjoin(
DataFrame(dataset(:ELP_ldt_trial)),
select(DataFrame(dataset(:ELP_ldt_item)), :item, :isword, :wrdlen),
on = :item
)
```
```{julia}
describe(trials, :min, :max, :nunique, :nmissing, :eltype)
```
## Fit a preliminary model
This takes about ten to fifteen minutes on a recent laptop
```{julia}
contrasts[:isword] = EffectsCoding()
contrasts[:wrdlen] = Center(8)
@time gm1 = let f = @formula(acc ~ 1 + isword * wrdlen + (1|item) + (1|subj))
fit(MixedModel, f, trials, Bernoulli(); contrasts, progress, init_from_lmm=(:β, :θ))
end
```
```{julia}
print(gm1)
```
```{julia}
#| fig-cap: Conditional modes and 95% prediction intervals on random effects for subject in model gm1
#| label: fig-gm1condmodesubj
#| code-fold: true
qqcaterpillar!(Figure(; size=(800,800)), gm1, :subj)
```