我正在使用HMM包来计算在R学习的学生的BKT组参数估计。现在,我的代码生成我想要的所有矩阵,除了最后的知识组件(代码中的kc)。但随后它继续运行一段时间,最终rstudio崩溃了。现在我的代码看起来像这样:
require("hmm.discnp")
## load student roll-up
df <- data.frame(read.table(file="C:/Users/Ajay Phatak/Documents/school/Summer 2015/150321GIPathwaysPreprocHCAtt183-31 M2A.txt",na.strings="NA",sep="\t",quote="",header=TRUE, fill=TRUE))
#df_subset <- df[,c(3,7,15,20,21,23)]
df_subset <- df[,c(5,21,27,39,38)]
#change first attempt to accuracy, change kc default to kc(model2a),
df_subset$Accuracy <- as.numeric(as.vector(df_subset$Accuracy))
df_subset <- na.omit(df_subset)
kc_list <- unique(df_subset$KC.Model.2A.)
#loop on the kc_list
for (kc in kc_list)
{
print(kc)
one_kc <- df_subset[ which(df_subset$KC.Model.2A.==kc), ]
one_kc <- one_kc[,c(1,3)]
# remove users with few observations on this skill
by_user = split(one_kc, one_kc$Anon.Student.id)
obs_by_user = sapply(by_user, nrow)
valid_users = names(obs_by_user[obs_by_user > 2])
student_outcomes = one_kc[one_kc$Anon.Student.id %in% valid_users,]
by_good_user = split(student_outcomes$Accuracy, student_outcomes$Anon.Student.id)
# attempt to estimate model parameters
my_hmm = hmm(by_good_user, yval=c(0,1),
par0=list(tpm=rbind(c(0.8,0.2),c(0.01,0.99)),
Rho=rbind(c(0.75,0.25),c(0.25,0.75))),
stationary=FALSE)
if (!my_hmm$converged) {
print(sprintf("Error! HMM did not converge for skill %s!", kc))
} else {
#for (user_id in valid_users) {
#student_est = sp(correct_by_user[[user_id]], object = my_hmm, means=TRUE)
#print(sprintf("%s/%s: %f chance know, %f chance correct", skill, user_id, student_est$probs[2,ncol(student_est$probs)], student_est$means[length(student_est$means)]))
# print(correct_by_user[[user_id]])
#}
}
# transition probability matrix
print(my_hmm$tpm)
# output probabilities
print(my_hmm$Rho)
# initial probabilities (don't know/know)
print(my_hmm$ispd)
}
数据是一个excel电子表格,其中每一行都是一个交易,列是学生ID,学生回答的kc,准确性以及其他一些不太重要的东西。关于为什么会崩溃的任何想法?