-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathfrac20_imv.R
35 lines (31 loc) · 1.01 KB
/
frac20_imv.R
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
source("00funs.R") ##https://github.com/ben-domingue/353a/blob/main/00funs.R
##you'll need to also install irwpkg & imv:
remotes::install_github("hansorlee/irwpkg")
devtools::install_github("ben-domingue/imv", ref="main")
#########################irw
f<-function(tab) {
df$resp <- as.numeric(df$resp) # Ensure the response variable is numeric
resp<-irwpkg::irw_long2resp(df)
resp$id<-NULL
makeqm<-function(df,resp=NULL) { #resp required for correct ordering
ii<-grep("Qmatrix__",names(df))
L<-split(df,df$item)
qm<-lapply(L,function(x,ii) colMeans(x[,ii],na.rm=TRUE),ii)
qm<-do.call("rbind",qm)
if (!is.null(resp)) {
cn<-colnames(resp)
qm<-qm[cn,]
}
qm
}
qm<-makeqm(df,resp=resp)
list(resp=resp,qm=qm)
}
om<-list()
tables<-'frac20'#c("frac20","cdm_ecpe","cdm_hr","mcmi_mokken")
for (table in tables) {
df<-irwpkg::irw_fetch(table)
L<-f(df)
om[[table]]<-oos.compare(L$resp,L$qm,5,modeltype="2PL")
}
unlist(om)