Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions inst/Regression/robustfit.m
Original file line number Diff line number Diff line change
Expand Up @@ -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(:);
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -322,3 +322,10 @@
%! robustfit (X, y, "huber", -1)
%!error <robustfit: CONST must be 'on' or 'off'.> ...
%! robustfit (X, y, "huber", 1.345, "maybe")

%!test
%! ## Edge cases with empty arrays
%!error<robustfit: Not enough points to perform robust estimation.> ...
%! robustfit ([], [])
%!error<robustfit: Not enough points to perform robust estimation.> ...
%! robustfit (zeros(0,3), zeros(0,1))