"R 1모수 모형"의 두 판 사이의 차이

35번째 줄: 35번째 줄:
<syntaxhighlight lang='r' notebook=irtplay>
<syntaxhighlight lang='r' notebook=irtplay>
plotICC <- function(model) {
plotICC <- function(model) {
  p1 <- model$estimates$par.1
  p2 <- model$estimates$par.2
  p3 <- model$estimates$par.3
  p3[is.na(p3)] <- 0
   D <- model$scale.D
   D <- model$scale.D
   x <- seq(-4, 4, .05)
   z <- seq(-4, 4, length=100)
   len <- dim(model$estimates)[1]
   len <- nrow(model$estimates)
   offset <- 1.5 - seq(0, 1.5, length=len)
   pos <- round(seq(10, 90, length=len))
   for( i in 1:len ) {
   for( i in 1:len ) {
    p1 <- model$estimates$par.1[i]
     f <- function(x) {p3[i]+(1-p3[i])*plogis(p1[i]*D*(x-p2[i]))}
    p2 <- model$estimates$par.2[i]
     if( i == 1 ) plot(z, f(z), type='l', col=i, ylim=c(0,1),
    p3 <- model$estimates$par.3[i]
    if(is.na(p1)) p1 <- 1
    if(is.na(p2)) p2 <- 0
    if(is.na(p3)) p3 <- 0
     f <- function(x) {p3+(1-p3)/(1+exp(-p1*D*(x-p2)))}
     if( i == 1 ) plot(x, f(x), type='l', col=i, ylim=c(0,1),
                       main="Item Characteristic Curves",
                       main="Item Characteristic Curves",
                       xlab="Ability",
                       xlab="Ability", ylab="Probability")
                      ylab="Probability")
     else lines(z, f(z), type='l', col=i, ylim=c(0,1))
     else lines(x, f(x), type='l', col=i, ylim=c(0,1))
     text(z[pos[i]], f(z[pos[i]]), adj=c(0,2), labels=c(paste('Item',i)), col=i)
     t <- p2 + offset[i]
    text(t, f(t), adj=c(0,2), labels=c(paste('Item',i)), col=i)
   }
   }
}
}

2021년 10월 3일 (일) 07:05 판

1 개요

R IRT 1모수 모형
R 문항반응이론 1PLM
R 문항반응이론 1모수 모형

2 ltm 패키지

df <- read.csv("https://github.com/jmnote/zdata/raw/master/github.com/cran/ltm/data/LSAT.csv")
library(ltm)
model <- rasch(df)

# 로그우도
model$log.Lik
# 계수
coef(model)
# 문항특성곡선
plot(model)
# 문항정보곡선
plot(model, "IIC")

3 irtplay 패키지

df <- read.csv("https://github.com/jmnote/zdata/raw/master/github.com/cran/ltm/data/LSAT.csv")
library(irtplay)
model <- est_irt(data=df, model="1PLM", verbose=FALSE)
coef(model)
plotICC <- function(model) {
  p1 <- model$estimates$par.1
  p2 <- model$estimates$par.2
  p3 <- model$estimates$par.3
  p3[is.na(p3)] <- 0
  D <- model$scale.D
  z <- seq(-4, 4, length=100)
  len <- nrow(model$estimates)
  pos <- round(seq(10, 90, length=len))
  for( i in 1:len ) {
    f <- function(x) {p3[i]+(1-p3[i])*plogis(p1[i]*D*(x-p2[i]))}
    if( i == 1 ) plot(z, f(z), type='l', col=i, ylim=c(0,1),
                      main="Item Characteristic Curves",
                      xlab="Ability", ylab="Probability")
    else lines(z, f(z), type='l', col=i, ylim=c(0,1))
    text(z[pos[i]], f(z[pos[i]]), adj=c(0,2), labels=c(paste('Item',i)), col=i)
  }
}
plotICC(model)

4 같이 보기

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