Skip to content

Commit e2b6f91

Browse files
authored
Merge pull request #70 from datapages/difficultysim
Difficultysim
2 parents ac7c6b8 + c48843e commit e2b6f91

8 files changed

Lines changed: 920 additions & 156 deletions

File tree

_quarto.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ website:
1010
left:
1111
- href: index.qmd
1212
text: Home
13-
- href: analysis.qmd
14-
text: Getting Started with the IRW Data
13+
- href: getstarted.qmd
14+
text: Getting Started
1515
- text: "IRW Data"
1616
menu:
1717
- href: data.qmd
@@ -26,6 +26,12 @@ website:
2626
text: Data Documentation
2727
- href: itemtext.qmd
2828
text: Item Text
29+
- text: "Tutorials"
30+
menu:
31+
- href: diffsim.qmd
32+
text: Difficulty Simulation
33+
- href: training.qmd
34+
text: Training Resources
2935
- text: "Competitions"
3036
menu:
3137
- href: comps_standard.qmd
@@ -38,8 +44,6 @@ website:
3844
text: Examples of IRW-related research
3945
- href: othersites.qmd
4046
text: Related data resources and publications
41-
- href: training.qmd
42-
text: Training Resources
4347
- href: contact.qmd
4448
text: Contact Us!
4549
right:

diffsim.qmd

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
---
2+
title: "Simulating Item Difficulties using IRW"
3+
---
4+
5+
Simulation is a powerful way to understand how psychometric models behave under different conditions. But many simulation studies make a simplifying assumption — that item difficulties follow a perfectly normal or uniform distribution. In reality, real-world measures rarely look that simple. Some have mostly easy items, others have clusters of hard ones, and some even show multiple peaks in difficulty levels.
6+
7+
This tutorial introduces a practical way to simulate realistic item difficulties based on empirical data drawn from IRW. Using the `irw` [R package](https://github.com/itemresponsewarehouse/Rpkg), you can easily generate item difficulties that reflect the diversity seen in real assessments rather than relying on artificial assumptions.
8+
9+
## How to Simulate Realistic Item Difficulties
10+
11+
Before simulation, we estimated item difficulties and their uncertainties across multiple IRW datasets and stored the results in a pooled database. Based on these estimates, empirical difficulty distributions were constructed by sampling according to the estimated parameters for each dataset (details refer to [Zhang et al., 2025](https://doi.org/10.31234/osf.io/jbhxy_v2)).
12+
The `irw_simu_diff()` function draws samples directly from these empirically derived distributions, rather than assuming a normal or uniform form, thereby generating realistic difficulty parameters that reflect both observed variability and estimation uncertainty.
13+
14+
```{r, eval=FALSE}
15+
# download the package
16+
devtools::install_github("itemresponsewarehouse/Rpkg")
17+
18+
# load the difficulty pool from the package
19+
data("diff_long", package = "irw")
20+
21+
# seed setting for simulation reproducibility
22+
set.seed(1)
23+
24+
# usage of the simu_item_diff() function
25+
simulated_difficulties <- irw::irw_simu_diff(
26+
num_items = 25,
27+
num_replications = 100,
28+
difficulty_pool = diff_long
29+
)
30+
# num_items and num_replications define the number of items and the number of simulation replications, respectively
31+
```
32+
33+
34+
35+
## Difficulty Estimates Pool
36+
37+
The current difficulty pool includes 145 datasets from IRW (as of 10-2025), covering a wide range of sample sizes and number of items.
38+
39+
<div style="text-align: center;">
40+
![](diffsim/n_nitems.png)
41+
</div>
42+
43+
44+
45+
46+
47+
Below is the figure showing how varied these distributions can be — some centered, some skewed, some even multimodal. This diversity helps us better understand how measurement behaves under realistic conditions.
48+
49+
50+
```{r, message = F}
51+
# load the difficulty pool from the package
52+
devtools::install_github("itemresponsewarehouse/Rpkg")
53+
data("diff_long", package = "irw")
54+
55+
# package for plot
56+
library(dplyr)
57+
library(ggplot2)
58+
library(ggridges)
59+
```
60+
61+
62+
```{r, fig.width=4, fig.height=7, fig.align='center'}
63+
diff_long_sd <- diff_long |>
64+
group_by(dataset) %>%
65+
mutate(SD = sd(difficulty, na.rm = TRUE)) %>%
66+
ungroup()
67+
68+
ggplot(diff_long_sd, aes(x = difficulty, y = reorder(dataset, SD), fill = SD)) +
69+
geom_density_ridges(scale = 3, alpha = 0.5, rel_min_height = 0.01) +
70+
scale_fill_gradient(low = "lightblue", high = "blue") +
71+
theme_classic() +
72+
theme(
73+
axis.text.y = element_blank(),
74+
axis.ticks.y = element_blank()
75+
) +
76+
labs(
77+
x = "Difficulty",
78+
y = NULL
79+
)
80+
```
81+
82+
<!--div style="text-align: center;">
83+
<img src="diffsim/ridge_irw.png" alt="Distribution of Item Difficulties" width="40%">
84+
85+
<p style="font-size: 0.9em; color: gray;"><strong>Note:</strong> The color intensity reflects the standard deviation of difficulties in each dataset, with darker shades signifying greater variability.</p>
86+
</div-->
87+
88+
89+
90+
The IRW database is growing. As new datasets are added, we will periodically update the difficulty pool in the `irw` package to reflect an even broader range of assessments.
91+
92+
93+
## A Small Simulation: Why Should We Care About Difficulty Distributions?
94+
95+
We ran a small simulation to show why the item difficulty distributions matter. In particular, we examined how different distributions affect the sample size required for accurate parameter estimation.
96+
97+
We used the empirical difficulty distributions from each of the datasets in the IRW pool.
98+
For each dataset, the procedure consisted of the following steps:
99+
100+
- Generate item difficulties: We sampled 50 items according to the empirical difficulty distribution from that dataset (as shown in the ridge plot above), and repeated this process 100 replications.
101+
102+
- Simulate response data and estimate parameters: For a given sample size $N$, we generated response data using a simple Rasch model with the known difficulties. We then estimated item difficulties from the simulated responses and computed the correlation between estimated and true parameters.
103+
104+
- Search for the minimal sufficient sample size: To efficiently determine how many respondents were needed to achieve a reliable recovery, we used a binary search between $N$ = 50 and 10,000. The search terminated once the average correlation across replications exceeded 0.95 and the gap between the lower and upper bounds of the search interval was less than 10.
105+
106+
107+
The sample size requirement analysis demonstrates the strong influence of item difficulty distribution on model estimation. The results (shown below) revealed notable differences across datasets: for some difficulty distributions, accurate recovery could be achieved with fewer than one hundred respondents, whereas for others, several hundred were needed to reach the same level of accuracy. This variation is independent of the number of items (given that we always sampled 50 items). When the standard deviation (SD) of item difficulty is below 1, a smaller SD indicates less variation among item difficulties, which requires a larger sample size. As the SD increases, the required sample size initially decreases, but once the SD becomes too large, the required sample size begins to increase again.
108+
109+
110+
<div style="text-align: center;">
111+
<img src="/diffsim/scatter_sd_logminn.png" alt="Distribution of Item Difficulties" width="60%">
112+
</div>
113+
114+
## Reference
115+
116+
For more details and additional simulation results, see:
117+
118+
- Zhang, L., Liu, Y., Molenaar, D., Gilbert, J.B., Kanopka, K., & Domingue, B.W. (2025). Realistic Simulation of Item Difficulties. [PsyArXiv](https://doi.org/10.31234/osf.io/jbhxy_v2).

diffsim/n_nitems.png

40 KB
Loading

diffsim/ridge_irw.png

172 KB
Loading

diffsim/scatter_sd_logminn.png

49.6 KB
Loading
File renamed without changes.

0 commit comments

Comments
 (0)