#'@title plotInformationCurve
#'@description Crea curva de informacion de un item
#'@param itemCodigo codigo del item
#'@import ggplot2
#'@export
plotInformationCurve = function(itemCodigo, parametros=NULL){
## busco parametros del item.
if(is.null(parametros)){
bancoItems <- getItemsCalibrados();
a <- bancoItems$a[which(bancoItems$ItemCodigo == itemCodigo)];
b <- bancoItems$b[which(bancoItems$ItemCodigo == itemCodigo)];
c <- bancoItems$c[which(bancoItems$ItemCodigo == itemCodigo)];
d <- bancoItems$d[which(bancoItems$ItemCodigo == itemCodigo)];
} else {
a <- parametros$a;
b <- parametros$b;
c <- parametros$c;
d <- parametros$d;
}
if(length(a) == 0){
plotHandler("Este item no fue calibrado")
} else {
## calculo curva caracteristica del item.
theta <- seq(-6, 3, by=0.01);
icc <- c + ( 1 - c )/(1 + exp(-a * (theta - b)));
## calculo de la curva de informacion del item.
info <- a^2*((icc - c)^2/(1 - c)^2)*((1 - icc)/icc)
myPlotData <- data.frame(theta=theta,
info=info);
## obtengo habilidades medias por grado
habilidadesMediasPorGrado <- calculateHabilidadesMediasPorGrado();
## grafico
gg <- ggplot(myPlotData, aes(x=theta, y=info)) + geom_line() +
geom_vline(data=habilidadesMediasPorGrado, aes(xintercept=meanHability, col=Grado),
linetype = "longdash", alpha=0.6) +
ylab(expression(I( theta ))) + xlab(expression(Habilidad (theta))) +
xlim(-6, 3) +
ggtitle(paste0("Curva de informacion (a=", round(a, 2), " b=", round(b, 2), ")"));
if(exists("myTheta")){
gg <- gg + geom_vline(data=data.frame(myTheta=myTheta), aes(xintercept=myTheta),
linetype = "longdash", alpha=0.6)
}
return(gg)
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.