You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
1.0 KiB
R
28 lines
1.0 KiB
R
9 months ago
|
library(mirt)
|
||
|
|
||
|
pcm_analysis <- function(df=NULL,treatment='TT',irtmodel='PCM2',method='MML') {
|
||
|
nbitems <- sum(sapply(1:20,function(x) paste0('item',x)) %in% colnames(df))
|
||
|
resp <- df[,sapply(seq(1,nbitems),function(x) paste0('item',x))]
|
||
|
if (method=='MML') {
|
||
|
tam1 <- tam.mml(resp=resp,Y=df[,treatment],irtmodel = irtmodel,est.variance = T,verbose=F)
|
||
|
}
|
||
|
if (method=='JML') {
|
||
|
tam1 <- tam.jml(resp=resp,group=1+df[,treatment])
|
||
|
}
|
||
|
if (method!='MML' & method!='JML') {
|
||
|
stop('Invalid method. Please choose among MML or JML')
|
||
|
}
|
||
|
return(tam1)
|
||
|
}
|
||
|
|
||
|
dff <- read.csv(file = '/home/corentin/Documents/These/Recherche/Simulations/Data/DIF/N50/scenario_5A_50.csv')
|
||
|
dfff <- dff[dff$replication==1,]
|
||
|
facets <- dfff$TT
|
||
|
dfff$item2_noTT <- NA
|
||
|
dfff$item2_TT <- NA
|
||
|
dfff[dfff$TT==0,]$item2_noTT <- dfff[dfff$TT==0,"item2"]
|
||
|
dfff[dfff$TT==1,]$item2_TT <- dfff[dfff$TT==1,"item2"]
|
||
|
|
||
|
mml.mod <- tam.mml(resp=dfff[,c('item1','item2_noTT','item2_TT',"item3","item4")],Y=dfff$TT,constraint='cases'
|
||
|
,irtmodel = "PCM2",est.variance = T,verbose=F)
|