Closed philwalk closed 2 weeks ago
Thanks for flagging this. I agree it shouldn't crash and burn so ungracefully, but the library implicitly assumes more observations than covariates. ie. that the problem is over-constrained. This is the typical use-case for linear regression. In your example, the problem is under-constrained (because there is actually a third covariate corresponding to the intercept, so you actually have more parameters than observations).
Ahh, that makes sense! I've been deep diving into the 3-pass regression filter, which has no such constraint.
Should I close this, or should I offer a PR with a better error message?
Perhaps this constraint should be applied to X
rather than Xmat
?
Yes, exactly. I will just add the extra constraint to X and then close this when I've done it. Thanks.
Ok, thanks for responding. The failure is much easier to understand with an updated constraint:
Exception in thread "main" java.lang.IllegalArgumentException: requirement failed
at scala.Predef$.require(Predef.scala:324)
at scalaglm.Lm.<init>(Lm.scala:43)
at scalaglm.Lm$.apply(Lm.scala:32)
at scalaglm.Lm$.apply(Lm.scala:266)
at scalaglm.Lm$.apply(Lm.scala:274)
at vast.apps.ABug$.main(ABug.scala:11)
at vast.apps.ABug.main(ABug.scala)
Constraint added and snapshot published. Closing now. Thanks.
Thanks for a really cool library!
The following code throws an
IllegalArgumentException
:In scalaglm.Lm the comment adjacent to the
QR.r
suggests that it's a p x p upper-triangular matrix. In this case, it's 2 x 3 matrix that looks something like this:Then
Lm
calls scalaglm.Utils.backSolve. This leads to a call toblas.dtrsv
, which fails because it requires parameter 6 (A.rows
== 2) to be <= parameter 4 (A.cols
==3).A
p x p
matrix would meet this requirement, so maybe the problem is a side-effect of calling qr.reduced, described here as returningmatrices Q and R with dimensions (m, k), (k, n) with k = min(m, n).
.I'm happy to offer a PR once I understand what ought to happen here.
Here's the stackdump: