Investigation: Quantitative epistemology#
Data analysis links measurements to claims through assumptions. Predicting an observation, estimating an association, and explaining a mechanism are different achievements. Statistical learning offers tools for assessing prediction; it does not settle every question about knowledge or causation.
Question. Use a simulated lexical-decision study to distinguish trial-level measurements, participant differences, a population association, and a prediction for a new participant.
Before running: write the result you expect and what would challenge it. Data are simulated unless explicitly identified otherwise.
# Open this notebook from book/notebooks (or book/exercises).
course_path <- if (file.exists("../R/course.R")) "../R/course.R" else "book/R/course.R"
stopifnot(file.exists(course_path))
source(course_path)
set.seed(432)
From observations to a claim#
A row is one participant–item trial. The mean below describes this simulated sample. The fitted coefficient describes a conditional association; the simulation code, not the fitted coefficient alone, identifies its generating process.
d <- simulate_trials()
stopifnot(!anyDuplicated(d$trial_id))
head(d)
c(trials = nrow(d), participants = nlevels(d$subject), mean_rt_ms = mean(d$rt))
fit <- lm(rt ~ frequency + length, d)
coef(fit)
plot(d$frequency, d$rt, xlab="Word frequency (simulated log scale)", ylab="Reaction time (ms)")
| trial_id | subject | item | length | frequency | rt | correct | |
|---|---|---|---|---|---|---|---|
| <int> | <fct> | <fct> | <int> | <dbl> | <dbl> | <int> | |
| 1 | 1 | 1 | 1 | 8 | 1.624019 | 646.9188 | 1 |
| 2 | 2 | 24 | 1 | 8 | 1.624019 | 606.2979 | 1 |
| 3 | 3 | 17 | 1 | 8 | 1.624019 | 717.1454 | 1 |
| 4 | 4 | 35 | 1 | 8 | 1.624019 | 591.9779 | 1 |
| 5 | 5 | 23 | 1 | 8 | 1.624019 | 734.8015 | 1 |
| 6 | 6 | 16 | 1 | 8 | 1.624019 | 610.3224 | 0 |
- trials
- 1080
- participants
- 36
- mean_rt_ms
- 633.692601761904
- (Intercept)
- 638.304513994777
- frequency
- -27.7494877537813
- length
- 11.9023751540681
A new participant is a different prediction target#
Hold out entire participants. These test trials contain familiar items but new participants. This estimates neither performance on new words nor transport to a different population.
s <- split_groups(d$subject)
fit <- lm(rt ~ frequency + length, d[s$train, ])
pred <- predict(fit, d[s$test, ])
c(model_mse = mse(d$rt[s$test], pred), baseline_mse = mse(d$rt[s$test], rep(mean(d$rt[s$train]), length(s$test))))
- model_mse
- 7433.20380774032
- baseline_mse
- 10529.5688905454
Interpret and verify#
Write one descriptive, one predictive, and one causal question about the same table. State what additional evidence each needs.
Failure to consider: A plausible explanation of a negative frequency–reaction-time association is not evidence that intervening on word frequency would cause the estimated change.
Report the target, the numerical result with its units, the relevant uncertainty, and one limitation. Distinguish what is established by the simulation from what would require real data.
AI audit: critique the saved faulty claim in the companion exercise before using any live assistant. If you use AI, record the relevant suggestion, your independent check, and the final decision.
Start here, then use openness to make the evidence behind a claim inspectable.
sessionInfo()
R version 4.2.1 (2022-06-23)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS 15.7.7
Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/libRlapack.dylib
locale:
[1] C.UTF-8/C.UTF-8/C.UTF-8/C/C.UTF-8/C.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] fansi_1.0.3 crayon_1.5.1 digest_0.6.29
[4] utf8_1.2.2 IRdisplay_1.1 repr_1.1.4
[7] lifecycle_1.0.1 jsonlite_1.8.0 evaluate_0.15
[10] pillar_1.8.0 rlang_1.0.6 cli_3.3.0
[13] uuid_1.1-0 vctrs_0.4.1 IRkernel_1.3.0.9000
[16] tools_4.2.1 glue_1.6.2 fastmap_1.1.0
[19] compiler_4.2.1 base64enc_0.1-3 pbdZMQ_0.3-7
[22] htmltools_0.5.3
Attribution#
Notebook authored by Ven Popov and edited by Krista Bond, Charles Wu, Patience Stevens, and Amy Sentis.
Revised investigation: 2026 course revision. Original authorship is retained; examples and explanatory text have been updated.