dexter-psychometrics / dexterMML

An add on to dexter for situations where CML estimation is impossible.
GNU General Public License v3.0
3 stars 0 forks source link

When dexterMML is used as a second step after starting a project from OPLM, then items that have been set off in OPLM are included in dexterMML analysis #2

Closed mometRie closed 1 year ago

mometRie commented 1 year ago

https://github.com/dexter-psychometrics/dexterMML/blob/23ffa1c6433825ebeae55406ab5d72dfcfaefe3e/R/ability.R#L14

mometRie commented 1 year ago

Is is possible to include this issue in dexterMML or have an external command to turn off items ?

jessekps commented 1 year ago

Sure, the help and examples in dexter::start_new_project_from_oplm show how to achieve this by using a predicate. Predicates are also supported in dexterMML::fit_1pl

mometRie commented 1 year ago

Sorry, i missed it. Can you ellaborate on this aspect a bit more in the help function? Is this matrix the same as a matrix that you would read in in OPLM in the option 'calibrate on of' in design menu?

jessekps commented 1 year ago

Oplm has three on/off settings for booklet, local item and global item. It uses 0 for off and 1 for on; iirc. This is the example in dexter::start_new_project_from_oplm

db = start_new_project_from_oplm('test.db',
   'path_to_scr_file', 'path_to_dat_file', 
   booklet_position=c(1,3), responses_start=101,
   person_id=c(50,62))

prms = fit_enorm(db, 
   item_global_on_off==1 & item_local_on_off==1 & booklet_on_off==1)

The second argument to fit_enorm above is called a predicate. It works the same as in the tidyverse packages, i.e. the dplyr filter statement. Many functions in dexter and dexterMML allow the use of a predicate. Just try it, it's fairly easy to use and offers great flexibility.

mometRie commented 1 year ago

Thank you Jesse, thats true for the case when dexter::fit_enorm is fitted.

But the issue that im having is a bit different:

`cal <- start_new_project_from_oplm("test1.db",scr_path = ".\OPLM\WK\TEST_R.scr", dat_path = "R:\10VDL_PA\IRT\OPLM\WK\WK_oplm.dat", booklet_position = c(1,2), responses_start = 4, use_discrim = TRUE)

everything goes well here

prms = fit_enorm(cal, item_global_on_off==1 & item_local_on_off==1 & booklet_on_off==1)

fit_1pl(cal, predicate = as.logical(pull(read_csv2(".\OPLM\WK\WK_vervallen.bkl"))) ) `

In the latter i'm getting an error:

Items with maximum score 0: [1] "Item_6" Error: Some items have a maximum score of 0, model cannot be calibrated

But item 6 has been turned off globally and also in the logical vector 'WK_vervallen.bkl'. It seems that the check about the maximum score needs an extension as a check if this item has been turned off or not.

I know it would be the best to not to have that item in the calibration, but i need it for the administration.

jessekps commented 1 year ago

I can see that will not work. A predicate must be a logical statement, not a logical vector. Try something ike this:

# uses settings in the screen file
p = fit_1pl(cal, item_global_on_off==1 & item_local_on_off==1 & booklet_on_off==1)

# turn off just item 6
p = fit_1pl(cal, item_id != "Item_6")

# really don't know what vervallen.bkl looks like, but something like
bk_vec = as.logical(pull(read_csv2(".\OPLM\WK\WK_vervallen.bkl"))) 
bk_on = as.character(which(bk_vec))
p = fit_1pl(cal, booklet_id %in% bk_on)
mometRie commented 1 year ago

Thanks, its even easier to apply it like this:

#apply dexter that also gives the item labels, as in the 'wk_vervallen.bkl' there are only 0/1 to show if the item from a given position is turned on/off

prms = fit_enorm(cal, item_global_on_off==1 & item_local_on_off==1 & booklet_on_off==1)

#apply 1pl MML with only calibrated items from OPLM
p = fit_1pl(cal, item_id %in% coef(prms)$item_id)