Introducción

Para el análisis de frecuencias y patrones en los errores en el aprendizaje del CPDnA se leen los datos del fichero LLP.csv proporcionado por Javier Villalva Díez.

#
setwd('~/git/JVD_HEALTH/JVD_LLP')
dd=read.csv(file="LLP3.csv",sep=",",skip=2,header=FALSE,stringsAsFactors=FALSE)
dd$row=as.numeric(rownames(dd))
colnames(dd)=c("Country","ID","Time","CW","PO","KPI",paste("Step_",1:(ncol(dd)-7),sep=""),"Row")
dd$Time=as.numeric(sub('CW','',dd$Time))

Vamos a agregar el rendimiento de cada PO

#
resume_ciclo=function(x) {
  res=ldply(x,function(u){
    dlT=which(u$Nerr==0)[1]
    lm1=lm(Nerr~ 1+CW,data=u[1:dlT,])
    return(data.frame(
      ID = u$ID[1],
      minT=u$Time[1],
      extT=nrow(u),
      dlT =which(u$Nerr==0)[1],
      nTE = sum(u$Nerr),
      FEL = u$Nerr[1],
      numE=length(which(u$Nerr==0)),
      i0  = coef(lm1)[1],
      i1  = coef(lm1)[2],
      iniK =u$KPI[1],
      avgKl=mean(u$KPI[which(u$Nerr==0)],na.rm=TRUE),
      sdKl=sd(u$KPI[which(u$Nerr==0)],na.rm=TRUE) ))
  })
  names(res)[which(names(res)==".id")]="idpo"
  return(res)
}
#
pintaPO=function(matcpdna,lppo,name=NULL){
  mint=min(matcpdna$minT)
  maxt=max(matcpdna$minT+matcpdna$extT-1)
  datp=as.data.frame(matrix(NA,ncol=(nrow(matcpdna)+1),nrow=(maxt-mint+1)))
  colnames(datp)=c("CW",rownames(matcpdna))
  datp[,1]=mint:maxt
  for(i in 1:nrow(matcpdna)) {
    j1=which(datp[,1]==matcpdna[i,"minT"])
    j2=which(datp[,1]==(matcpdna[i,"extT"]+matcpdna[i,"minT"]-1))
    datp[j1:j2,(i+1)] = lppo[[i]]$Nerr
  }
  datpm=melt(datp,.(CW))
  colnames(datpm)[2]="CPDnA"
  p = ggplot(data=datpm,aes(x=CW,y=value,group=CPDnA, colour=CPDnA)) + 
      geom_line() + geom_point() + theme_bw() +  ylab("Num. of Errors")
  print(p)
}
#
dd2 = dd[,c(1:6,ncol(dd))]
dd2$Nerr = apply(dd[,7:(ncol(dd)-1)],1,sum,na.rm=T)
ddl=split(dd2,f=dd2[,"ID"])
#
lpo=list()
idx=ldply(ddl,function(x){return(x$PO[1])})
for (i in 1:max(dd2$PO)) {
  lpo[[i]]=ddl[idx[idx[,2]==i,1]]
  names(lpo[[i]])=1:length(lpo[[i]])
  names(lpo)[i]=paste("PO",i,sep="")
}
#
respo=lapply(lpo,resume_ciclo)
for(i in 1:length(respo)) {
  pintaPO(respo[[i]],lpo[[i]])
}

#

Representación de los patrones de aprendizaje

#
print(xtable(ldply(respo)),type="html")
.id idpo ID minT extT dlT nTE FEL numE i0 i1 iniK avgKl sdKl
1 PO1 1 1 1.00 13 9 44 10 5 10.81 -1.18 100 32.40 2.07
2 PO1 2 2 10.00 8 4 12 5 5 7.50 -1.80 100 69.20 9.20
3 PO1 3 3 9.00 3 3 6 5 1 7.00 -2.50 100 92.00
4 PO2 1 4 1.00 21 17 86 10 5 10.44 -0.60 107 52.40 2.97
5 PO2 2 5 10.00 12 8 31 8 5 8.54 -1.04 100 56.40 3.65
6 PO2 3 6 13.00 9 5 18 6 5 8.10 -1.50 100 71.40 6.54
7 PO2 4 7 17.00 8 4 8 5 5 6.00 -1.60 100 83.60 3.58
8 PO3 1 8 1.00 11 6 40 10 5 11.80 -1.94 100 95.00 9.35
9 PO3 2 9 4.00 14 10 39 8 5 7.80 -0.71 89 54.60 3.36
10 PO3 3 10 10.00 9 5 23 10 5 11.20 -2.20 100 60.20 1.92
11 PO3 4 11 14.00 7 3 6 5 5 7.00 -2.50 100 90.60 7.06
12 PO4 1 12 1.00 14 10 47 10 5 10.33 -1.02 100 68.40 2.70
13 PO4 2 13 4.00 10 6 29 9 5 11.13 -1.80 100 74.20 3.27
14 PO4 3 14 10.00 14 10 48 10 5 10.20 -0.98 100 94.00 3.74
15 PO4 4 15 14.00 9 5 15 5 5 7.20 -1.40 89 84.00 1.58
#