diff --git a/inst/Regression/robustfit.m b/inst/Regression/robustfit.m index 43d4d8d96..849e29f90 100644 --- a/inst/Regression/robustfit.m +++ b/inst/Regression/robustfit.m @@ -70,7 +70,7 @@ if (! (isnumeric (X) && isreal (X) && ismatrix (X))) error ("robustfit: X must be a real matrix."); endif - if (! (isnumeric (y) && isreal (y) && isvector (y))) + if (! (isnumeric (y) && isreal (y) && (isvector (y) || isempty (y)))) error ("robustfit: Y must be a real vector."); endif y = y(:); @@ -114,7 +114,7 @@ endif [n, p] = size (X); if (n <= p) - error ("robustfit: not enough observations for the number of parameters."); + error ("robustfit: Not enough points to perform robust estimation."); endif ## Ordinary least squares start, leverages, and the OLS scale. @@ -322,3 +322,10 @@ %! robustfit (X, y, "huber", -1) %!error ... %! robustfit (X, y, "huber", 1.345, "maybe") + +%!test +%! ## Edge cases with empty arrays +%!error ... +%! robustfit ([], []) +%!error ... +%! robustfit (zeros(0,3), zeros(0,1))