1 개요[ | ]
- Python 등급반응모형
2 데이터[ | ]
Python
Reload
Copy
import numpy as np
import pandas as pd
import girth
df = pd.read_csv("https://raw.githubusercontent.com/jmnote/zdata/master/github.com/cran/ltm/data/Science.csv")
df = df.iloc[:,[0,2,3,6]] # 문항 4개 선택
df.shape # 392명 x 4문항
Loading
Copy
# 문항별 반응종류 및 빈도
df.apply(pd.Series.value_counts)
Loading
Copy
# 행렬로 변환
m = np.transpose(df.values)
# 4점 척도 적용
m[m=='strongly disagree'] = 1
m[m=='disagree'] = 2
m[m=='agree'] = 3
m[m=='strongly agree'] = 4
m = m.astype('int')
m
Loading
3 예시1: JML 방법[ | ]
- Joint Maximum Likelihood Methods
Copy
# 모델 적합
fit = girth.grm_jml(m)
# 난이도 -- 4행(문항수) x 3열(부분점수경계)
fit['Difficulty']
Loading
Copy
# 변별도
fit['Discrimination']
Loading
4 예시2: MML 방법[ | ]
- Maximum Marginal Likelihood Methods
Copy
# 모델 적합
fit = girth.grm_mml(m)
# 난이도 -- 4행(문항수) x 3열(부분점수경계)
fit['Difficulty']
Loading
Copy
# 변별도
fit['Discrimination']
Loading
Copy
# AIC
fit['AIC']
Loading
Copy
# 참가자 능력 분포
import matplotlib.pyplot as plt
plt.hist(fit['Ability'])
plt.show()
Loading
5 같이 보기[ | ]
편집자 Jmnote
로그인하시면 댓글을 쓸 수 있습니다.