Closed cblandhol closed 3 years ago
I'm not sure if this is true:
If I understand it correctly this is because direct MTR regression does not work with splines as bases functions because we cannot express the constraints in terms of equation (6) in the documentation posted in issue #194.
If it is, I can't remember the rationale. There isn't anything inherently more difficult about constraining splines than constraining other functions (splines are at the end of the day just piecewise polynomials). And @jkcshea 's example in #194 had shape constraints with the audit procedure. So I think this is a bug.
Hm, this is indeed an error. The direct MTR regression is supposed to support splines, I remember having an exchange with @slacouture about this... I will take care of this!
This is resolved now.
When testing the rescaling methods, I did not consider cases where variables were 0 for all observations.
But in the example above, some of the spline components are 0 for all observations.
These variables therefore have a norm of 0.
But when rescaling the data, we divide each variable by its norm---so we were dividing by zeroes.
That was why R was reporting Error in lm.fit(x = resX, y = drY) : NA/NaN/Inf in 'x'
So to resolve this issue, variables with norm 0 are assigned a norm of 1.
@cblandhol let me know if this works for you, too.
Makes perfect sense, and I guess this must have been happening before lm
goes through and drops collinear variables.
Thanks @jkcshea !
The direct MTR regression throws an uninformative error when using splines in the basis functions. If I understand it correctly this is because direct MTR regression does not work with splines as bases functions because we cannot express the constraints in terms of equation (6) in the documentation posted in issue #194.
It would be helpful if the error message was more informative. Here is an example that illustrates the behavior and the error message: