全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SPSS论坛
2323 2
2014-04-30
PRESERVE.
GET FILE='c:\temp\ItemAnalysisExercise.sav'.
SET TVARS=LABELS /TNUMBERS=LABELS.
COMPUTE ID=$CASENUM.
SORT CASES BY ID (D).
DO REPEAT key=#1 TO #10/ q=q1 TO q10.
+ DO IF $CASENUM=1.
+   COMPUTE key=q.
+  ELSE.
+   COMPUTE q=(q=key).
+ END IF.
END REPEAT.
XSAVE OUTFILE  "c:\temp\SCORED.sav"/DROP=id.
EXECUTE .
GET FILE="c:\temp\SCORED.sav.".

***Delete the record containing the key.
SORT CASES BY name (A).
SELECT IF(name NE 'key').

***Compute the score for each record.
COMPUTE score=MEAN(q1 to q10)*100.

***Compute and append the ranking of each score.
RANK VARIABLES=score (D) /NTILES (3) /PRINT=NO /TIES=MEAN .

***Clean up.
RENAME VARIABLES (nscore=group).
FORMATS score (f8.0).
VALUE LABELS group 1 'high' 2 'middle' 3 'low'.
SAVE OUTFILE 'c:\temp\scored.sav'.

***run against the resulting scored data to produce the output seen in Figures 3-4.
AGGREGATE OUTFILE=*
/BREAK=group
/q1 'percentage right q1'=MEAN(q1)
/q2 'percentage right q2'=MEAN(q2)
/q3 'percentage right q3'=MEAN(q3)
/q4 'percentage right q4'=MEAN(q4)
/q5 'percentage right q5'=MEAN(q5)
/q6 'percentage right q6'=MEAN(q6)
/q7 'percentage right q7'=MEAN(q7)
/q8 'percentage right q8'=MEAN(q8)
/q9 'percentage right q9'=MEAN(q9)
/q10 'percentage right q10'=MEAN(q10).
FLIP VARIABLES=q1 TO q10 /NEWNAMES=group.
RENAME VARIABLES (case_lbl=qnum) (v1=high) (v2=middle) (v3=low).
COMPUTE index=high - low.
FORMATS high TO index (F4.2).
SUMMARIZE
  /TABLES=qnum high middle low index
  /FORMAT=VALIDLIST NOCASENUM TOTAL
  /TITLE='Index of Discrimination'
  /MISSING=VARIABLE
  /CELLS=NONE.



***Compute - among other things - corrected point biserial correlations.
GET FILE 'c:\temp\scored.sav'.
RELIABILITY
/VARIABLES=q1 TO q10
/FORMAT=NOLABELS
/SCALE(ALPHA)=ALL/MODEL=ALPHA
/STATISTICS=DESCRIPTIVE CORR
/SUMMARY=TOTAL MEANS.


*** Produce a table similar to that in figure 5

***Item distracter analysis setup.
GET FILE='c:\temp\ItemAnalysisExercise.sav'.

SELECT IF name="key".
FORMATS q1 TO q10(F1).

*//////////.
DEFINE !keys(nbq=!TOKENS(1))
/* This macro adds the * after the correct answer number */
WRITE OUTFILE='c:\temp\define labels.sps'
!DO !cnt=1 !TO !nbq /!QUOTE(!CONCAT('ADD VALUE LABEL q',!cnt," "))!CONCAT(q,!cnt)'"'!CONCAT(q,!cnt)'*".'
!DOEND.
EXECUTE.
!ENDDEFINE.
*//////////.

SET MPRINT=yes.
!keys nbq=10.


GET FILE='c:\temp\ItemAnalysisExercise.sav'.
SELECT IF (name ne 'key').
MATCH FILES/FILE=*
/FILE='C:\TEMP\scored.sav'
/RENAME (name q1 TO q10= d0 TO d10)
/DROP=d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 d10.

VARIABLE LABELS group 'Percentage answering distracter'.
VALUE LABELS group 1 'high 1/3' 2 'middle 1/3' 3 'low 1/3'.
INCLUDE 'c:\temp\define labels.sps'.
CROSSTABS
/TABLES=group BY q1 TO q10
/FORMAT=AVALUE TABLES
/CELLS=ROW.

RESTORE.
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2014-4-30 12:54:31
*//////////.
DEFINE !keys(nbq=!TOKENS(1))
/* This macro adds the * after the correct answer number */
WRITE OUTFILE='define labels.sps'
!DO !cnt=1 !TO !nbq /!QUOTE(!CONCAT('VALUE LABELS q',!cnt," "))!CONCAT(q,!cnt)' "'!CONCAT(q,!cnt)'*".'
!DOEND.
EXECUTE.
!ENDDEFINE.
*//////////.


*////////////////////////////.
DEFINE !item(fileName=!TOKENS(1) /nbQuestions = !TOKENS(1))

CD !fileName.
DATASET CLOSE ALL .
GET FILE = !fileName .
PRESERVE.
SET TVARS=LABELS /TNUMBERS=LABELS.
COMPUTE id_tmp = $CASENUM.
SORT CASES BY id_tmp(D).
COMPUTE id_key = ($CASENUM=1).
DO REPEAT key=#1 TO !CONCAT('#',!nbQuestions)   / q=q1 TO !CONCAT('q',!nbQuestions).
- DO IF $CASENUM=1.
-   COMPUTE key = q.
- ELSE.
-   COMPUTE q = (q=key).
- END IF.
END REPEAT.

SORT CASES BY id_tmp (A).
***Delete the record containing the key.
SELECT IF NOT id_key.

***Compute the score for each record.
COMPUTE score = MEAN(q1 TO !CONCAT('q',!nbQuestions))*100.

***Compute and append the ranking of each score.
RANK VARIABLES = score (D) /NTILES (3) INTO group /PRINT=YES /TIES=MEAN .
FORMATS group (F8).
VALUE LABELS group 1 'high' 2 'middle' 3 'low'.
SAVE OUTFILE='scored.sav'.

***run against the resulting scored data to produce the output seen in Figures 3-4.
AGGREGATE OUTFILE=*
/BREAK=group !DO !idx=1 !TO !nbQuestions
/!CONCAT('q',!idx, ' "percentage right q',!idx,'"=MEAN(q',!idx,')' ) !DOEND.

STRING nnames(A3).
COMPUTE nnames = CONCAT('v',LTRIM(STRING(group,F8))).

FLIP VARIABLES=q1 TO !CONCAT('q',!nbQuestions) /NEWNAMES=nnames.
RENAME VARIABLES (case_lbl=qnum) (v1=high) (v2=middle) (v3=low).
COMPUTE index = high - low.
FORMATS high TO index (F4.2).
SUMMARIZE
  /TABLES=qnum high middle low index
  /FORMAT=VALIDLIST NOCASENUM TOTAL
  /TITLE='Index of Discrimination'
  /MISSING=VARIABLE
  /CELLS=NONE.

***Compute - among other things - corrected point biserial correlations.
GET FILE= 'scored.sav'.
RELIABILITY
  /VARIABLES=q1 TO !CONCAT('q',!nbQuestions)
  /FORMAT=NOLABELS
  /SCALE(ALPHA)=ALL/MODEL=ALPHA
  /STATISTICS=DESCRIPTIVE CORR
  /SUMMARY=TOTAL MEANS.

*** Produce a table similar to that in figure 5.

***Item distracter analysis setup.
GET FILE=!fileName .
COMPUTE nobreak=1.
ADD FILES FILE=* /BY=nobreak /LAST=id_key.
SELECT IF NOT id_key.
FORMATS q1 TO !CONCAT('q',!nbQuestions)(F1).

!keys nbq=!nbQuestions.

GET FILE=!fileName .
COMPUTE nobreak=1.
ADD FILES FILE=* /BY=nobreak /LAST=id_key.
SELECT IF NOT id_key.
MATCH FILES/FILE=*
  /FILE='scored.sav'
  /RENAME (q1 TO !CONCAT('q',!nbQuestions)= d1 TO  !CONCAT('d',!nbQuestions))
  /DROP=d1 TO !CONCAT('d',!nbQuestions)).

VARIABLE LABELS group 'Percentage answering distracter'.
VALUE LABELS group 1 'high 1/3' 2 'middle 1/3' 3 'low 1/3'.
FORMATS q1 TO  !CONCAT('q',!nbQuestions) (F8).
INSERT FILE='define labels.sps'.
CROSSTABS
  /TABLES=group BY q1 TO !CONCAT('q',!nbQuestions)
  /FORMAT=AVALUE TABLES
  /CELLS=ROW.

RESTORE.
!ENDDEFINE.
*////////////////////////////.

SET MPRINT=YES.

!item fileName="c:\temp\ItemAnalysisExercise.sav"  nbQuestions =10 .
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2018-6-22 17:02:33
里面的数据文件哪里下载
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群