Python 등급반응모형

1 개요[ | ]

Python 등급반응모형

2 데이터[ | ]

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문항
# 문항별 반응종류 및 빈도
df.apply(pd.Series.value_counts)
# 행렬로 변환
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

3 예시1: JML 방법[ | ]

  • Joint Maximum Likelihood Methods
# 모델 적합
fit = girth.grm_jml(m)

# 난이도 -- 4행(문항수) x 3열(부분점수경계)
fit['Difficulty']
# 변별도
fit['Discrimination']

4 예시2: MML 방법[ | ]

  • Maximum Marginal Likelihood Methods
# 모델 적합
fit = girth.grm_mml(m)

# 난이도 -- 4행(문항수) x 3열(부분점수경계)
fit['Difficulty']
# 변별도
fit['Discrimination']
# AIC
fit['AIC']
# 참가자 능력 분포
import matplotlib.pyplot as plt
plt.hist(fit['Ability'])
plt.show()

5 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}