JanaJarecki/cognitivemodels

Error messages after wrong parameter inputs are difficult to understand

Closed this issue · 3 comments

Is valid for both cpt and shortfall

In case an invalid parameter is used (e.g., angle = "size), cpt renders the error "Error: Parameter ‘alpha’ can range from 0.001 to 2, but it was fixed to 0." and shortfall renders the error " Error in apply(A[, 1:m], 1, function(x) max(abs(x)) <= tol) : dim(X) must have a positive length".

In case a parameter is set to NA, cpt and shortfall render the error " Error in ROI::L_constraint(L = L, rhs = unlist(fix[sapply(fix, is.numeric)]), : all(c(dim_L[1], n_dir) == n_L_constraints) is not TRUE"

Thanks - @FlorianSeitz to reproduce, can you copy-paste the exact model code that produces the bad errors here?
That's the easiest then I can copy-paste it quick and try myself

Lines 62-63, # 1.b. Parameter restrictions

expect_error(cpt(rp ~ x1 + px + x2 | y1 + py + y2, ref = 0, data = dt, fix = list(angle = "size")))

expect_error(cpt(rp ~ x1 + px + x2 | y1 + py + y2, ref = 0, data = dt, fix = list(c(tk_par[names(tk_par) != "lambda"], lambda = NA))))

fixed in 12a9772