Skip to content

Instantly share code, notes, and snippets.

@jacobmischka
Created April 19, 2017 15:50
Show Gist options
  • Save jacobmischka/9749a3b2cece0e9a5ea83aae5bba4309 to your computer and use it in GitHub Desktop.
Save jacobmischka/9749a3b2cece0e9a5ea83aae5bba4309 to your computer and use it in GitHub Desktop.
CatAlgorithmPromis Diff
diff --git a/src/main/java/edu/stanford/survey/server/CatAlgorithmPromis.java b/src/main/java/edu/stanford/survey/server/CatAlgorithmPromis.java
index cbf03a8e..a8cca090 100644
--- a/src/main/java/edu/stanford/survey/server/CatAlgorithmPromis.java
+++ b/src/main/java/edu/stanford/survey/server/CatAlgorithmPromis.java
@@ -70,7 +70,8 @@ public CatAlgorithm initialize(ItemBank itemBank) {
int nCategory = 0;
for (Response r : item.responses()) {
if (r.difficulty() < 1 || r.difficulty() > item.betas().length + 1) {
- throw new IllegalArgumentException("Item " + item.code() + " has a response with a difficulty out of range");
+ log.debug("Item " + item.code() + " has a response with a difficulty out of range");
+ continue;
}
nCategory = Math.max(nCategory, r.difficulty());
}
@@ -186,6 +187,11 @@ public Score score(List<Response> currentAssessmentResponses) {
double[] loglik = new double[thetas.length];
if (currentAssessmentResponses != null) {
for (Response response : currentAssessmentResponses) {
+ if (response.difficulty() < 1 || response.difficulty() > response.item().betas().length + 1) {
+ // FIXME: This doesn't work with measures with intentional values of 0
+ log.debug("Item " + response.item().code() + " has a response with a difficulty out of range");
+ continue;
+ }
for (int i = 0; i < loglik.length; i++) {
// Note the shift to one -1 difficulty: IMPORTANT!!!!
loglik[i] += itemCodeToLpMatrix.get(response.item().code())[i][response.difficulty() - 1];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment