Hi, I'm working on conducting an item analysis for 60 test items by calculating the item difficulty and item discrimination index. After that, I intend to generate a new dataset with the variables Item_Num, Item Difficulty, and Item Discrimination Index. Below is the code I'm using.
And this is the response I am getting
observation number out of range
Observation number must be between 183 and 2,147,483,619. (Observation numbers are typed
without commas.)
r(198);
What could I be doing wrong or how do I go around this?
An extract of my dataset and the desired table are below
Code:
capture program drop item_analysis program item_analysis args total_score item_list if "`total_score'" == "" { di "You must specify the total score variable." exit } if "`item_list'" == "" { di "You must specify the list of item variables." exit } tempfile results preserve local nitems = `: word count `item_list'' set obs `nitems' gen Item = "" gen Item_Difficulty = . gen Discrimination_Index = . correlate `item_list' `total_score', covariance local row = 1 foreach item of varlist `item_list' { di "-----------------------------" di "Item Analysis for: `item'" di "-----------------------------" sum `item' local difficulty = r(mean) local discrim_index = r(`item'_`total_score') replace Item = "`item'" in `row' replace Item_Difficulty = `difficulty' in `row' replace Discrimination_Index = `discrim_index' in `row' local row = `row' + 1 } save `results', replace restore append using `results' list Item Item_Difficulty Discrimination_Index end gen total_score = 0 forval i = 1/60 { replace total_score = total_score + Item`i' if !missing(Item`i') } * Ensure total_score is an integer replace total_score = round(total_score) item_analysis total_score Item1-Item60
And this is the response I am getting
observation number out of range
Observation number must be between 183 and 2,147,483,619. (Observation numbers are typed
without commas.)
r(198);
What could I be doing wrong or how do I go around this?
An extract of my dataset and the desired table are below
Code:
StudentNumberid Item1 Item2 Item3 Item4 Item5 Item6 Item7 Item8 Item9 Item10 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 3 1 1 1 1 1 1 1 1 1 1 4 1 1 1 1 1 1 1 1 1 1 5 1 1 1 1 1 1 1 1 1 1 6 1 1 1 1 1 1 1 1 1 1 7 1 1 1 1 1 1 1 1 1 1 8 1 1 1 1 1 1 1 1 1 1 9 1 1 1 1 1 1 1 1 1 1 10 1 1 1 1 1 1 1 1 1 1 11 1 1 1 1 1 1 1 1 1 1 12 1 1 1 1 1 1 1 1 1 1 13 1 1 1 0 1 1 1 1 1 1 14 1 1 0 0 1 1 1 1 1 1 15 1 1 1 1 1 1 1 1 1 1 16 1 1 0 0 1 1 1 1 1 1 17 1 1 1 1 1 1 1 1 1 1 18 1 1 1 1 1 1 1 1 1 1 19 1 1 1 1 1 1 1 1 1 1 20 1 1 1 1 1 1 1 1 1 1 21 1 1 1 1 1 1 1 1 1 1
Code:
Item Difficulty Index Disc. Index #1 0.19 0.31 #2 0.48 0.65 #3 0.18 0.29 #4 0.31 0.41 #5 0.72 -0.12 #6 0.40 0.54 #7 0.27 -0.01 #8 0.13 0.05 #9 0.13 0.29 #10 0.47 0.60 #11 0.18 0.10 #12 0.22 0.24 #13 0.25 0.33 #14 0.26 0.00 #15 0.44 0.15 #16 0.33 -0.14 #17 0.24 0.45 #18 0.62 0.71 #19 0.41 0.59 #20 0.30 0.51 #21 0.27 0.20 #22 0.27 0.22
Comment