-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpc-2.qmd
109 lines (92 loc) · 2.48 KB
/
pc-2.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# Fitting the Partial Credit Model
You can fit the Partial Credit Model in either dexter or TAM. Let's start with dexter.
```{r}
#| include: true
#| echo: true
#| output: false
#| warning: false
rm(list=ls())
library(tidyverse)
library(dexter)
# load in the dataset
responses <- read_csv('data/pc-data.csv')
# recode NA as 0 across all columns
responses <- responses %>%
mutate_if(is.numeric, ~replace_na(., 0))
# load the data summary
data_summary <- read_csv('data/pc-data-summary.csv')
```
```{r}
#| include: true
#| echo: true
#| output: false
#| warning: false
# Create the rules from the summary
# create an empty tibble with three columns item_id, response, and item_score
rules <- tibble(item_id = character(), response = character(), item_score = numeric())
# for each row in the data summary create a rule
for (i in 1:nrow(data_summary)) {
# get the item id
item_id <- data_summary$Variable[i]
# get the maximum mark
max_mark <- data_summary$`Maximum possible mark`[i]
# for every mark from 0 to max_mark create a rule
for (mark in 0:max_mark) {
# create a rule for the mark
rule <- tibble(item_id = item_id, response = as.character(mark), item_score = mark)
# add the rule to the rules tibble
rules <- bind_rows(rules, rule)
}
}
```
```{r}
#| include: true
#| echo: true
#| output: true
#| warning: false
# create a new project
db <- start_new_project(rules, db_name = ":memory:", person_properties=list(sex="unknown",grade="unknown"))
# add the response data
add_booklet(db, responses, "geography")
```
```{r}
#| include: true
#| echo: true
#| output: true
#| warning: false
# print the item tables
tt = tia_tables(db)
knitr::kable(tt$items, digits=2)
```
## Expected Score Curves
```{r}
#| include: true
#| echo: true
#| output: true
#| warning: false
m = fit_inter(db)
n_items <- nrow(data_summary)
for(i in 1:n_items){
plot(m, data_summary$Variable[i], show.observed=TRUE)
}
```
## Item Difficulty
```{r}
#| include: true
#| echo: true
#| output: true
#| warning: false
m = fit_inter(db)
n_items <- nrow(data_summary)
for(i in 1:n_items){
plot(m, data_summary$Variable[i], summate=FALSE, show.observed=FALSE)
}
# plot(m, "C3_1ai", summate=FALSE, show.observed=FALSE)
# plot(m, "C3_1ai", summate=TRUE, show.observed=TRUE)
close_project(db)
```
```{r}
```
## Take a look at the SPAG items. How well are they working?
## Extension exercise
Try fitting the Partial Credit Mode in TAM. What differences / similarities do you notice? Which do you prefer?