Corrected bugs + TAM dif analysis
This commit is contained in:
1000
RProject/.Rhistory
1000
RProject/.Rhistory
File diff suppressed because it is too large
Load Diff
27
RProject/dif.R
Normal file
27
RProject/dif.R
Normal file
@ -0,0 +1,27 @@
|
||||
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)
|
Reference in New Issue
Block a user