Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
d78339d
Fix categorical variable mapping in grp2idx
Pasta-coder Apr 6, 2026
5926115
dummyvar: fix categorical encoding to match MATLAB semantics
Pasta-coder Apr 12, 2026
83255e7
parseWilkinsonFormula: fix 5 polynomial and MATLAB-compatibility issu…
Pasta-coder Apr 12, 2026
2c2c9c4
minor cleanup
Pasta-coder Apr 12, 2026
53f1c88
Implement CompactLinearModel core class and OLS math engine
Pasta-coder Apr 13, 2026
e5885aa
cleanup
Pasta-coder Apr 13, 2026
70b0ce8
feat: implement LinearModel with diagnostics, compact model updates, …
Pasta-coder Apr 13, 2026
1f81462
linearmodel_final
Pasta-coder Apr 13, 2026
1982ba6
Implement factory function and integrate with
Pasta-coder Apr 13, 2026
b455d01
feat(statistics): implement stepwiselm and LinearModel.step
Pasta-coder Apr 13, 2026
3eeb6db
dummyvar: accept row vectors
Pasta-coder Apr 16, 2026
2f62cc5
grp2idx: Add empty‑input guard at top to return [] and {}
Pasta-coder Apr 16, 2026
0aede6b
implement stepwiselm
Pasta-coder Apr 17, 2026
f38b853
fix(stats): enforce strict input validation for empty arrays in grp2idx
Pasta-coder Apr 17, 2026
e18687e
fix(stats): enforce strict input shape and type constraints in dummyvar
Pasta-coder Apr 17, 2026
7e363f7
feat(fitlm): implement full Wilkinson formula parser and shorthand su…
Pasta-coder Apr 17, 2026
44bba7e
fix(fitlm): convert categorical to cellstr before ismember to fix dim…
Pasta-coder Apr 17, 2026
6aa275d
fix(fitlm): sort terms by MATLAB canonical order (degree, max power, …
Pasta-coder Apr 17, 2026
15a0628
feat(fitlm): strict formula validation and DummyVarCoding full support
Pasta-coder Apr 17, 2026
5a46377
feat: Coefficients as table, Formula as LinearFormula object
Pasta-coder Apr 17, 2026
79ae814
feat(predict): table input support and feval method
Pasta-coder Apr 17, 2026
ee727e1
Refactor LinearModel properties to return table objects
Pasta-coder Apr 19, 2026
32f3b3f
remove reduntant tests
Pasta-coder Apr 19, 2026
a95db53
currently CompactLinearModel properties are readonly
Pasta-coder Apr 19, 2026
8418eca
fitlm : remove failing bists
Pasta-coder Apr 19, 2026
d13d5c2
dummyvar : 1 bist removed
Pasta-coder Apr 19, 2026
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
786 changes: 786 additions & 0 deletions inst/CompactLinearModel.m

Large diffs are not rendered by default.

122 changes: 122 additions & 0 deletions inst/LinearFormula.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
## Copyright (C) 2026 Jayant Chauhan <0001jayant@gmail.com>
##
## This file is part of the statistics package for GNU Octave.
##
## This program is free software; you can redistribute it and/or modify it under
## the terms of the GNU General Public License as published by the Free Software
## Foundation; either version 3 of the License, or (at your option) any later
## version.
##
## This program is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
## details.
##
## You should have received a copy of the GNU General Public License along with
## this program; if not, see <http://www.gnu.org/licenses/>.

classdef LinearFormula
## -*- texinfo -*-
## @deftp {statistics} LinearFormula
##
## Linear formula encapsulation class.
##
## A @code{LinearFormula} object encapsulates the internal formula
## representation for a @code{LinearModel} or @code{CompactLinearModel}.
## When displayed in the console, it shows only the human-readable
## formula string (e.g., @code{y ~ 1 + x1 + x2}).
##
## @strong{Properties}
##
## @multitable @columnfractions 0.30 0.70
## @headitem Property @tab Description
## @item @code{ResponseName} @tab Name of the response variable.
## @item @code{LinearPredictor} @tab Human-readable formula string.
## @item @code{Terms} @tab Binary terms matrix (n_terms x p).
## @item @code{HasIntercept} @tab Logical: true if model has intercept.
## @item @code{InModel} @tab Logical vector indicating which terms are
## active.
## @item @code{CoefficientNames} @tab Cell array of coefficient names.
## @item @code{PredictorNames} @tab Cell array of predictor names.
## @item @code{VariableNames} @tab Cell array of all variable names.
## @end multitable
##
## @seealso{fitlm, LinearModel, CompactLinearModel}
## @end deftp

properties (SetAccess = protected)
ResponseName = "";
LinearPredictor = "";
Terms = [];
HasIntercept = true;
InModel = [];
CoefficientNames = {};
PredictorNames = {};
VariableNames = {};
endproperties

methods

function obj = LinearFormula (s)
## LinearFormula Constructor.
##
## obj = LinearFormula (s)
##
## S is a struct with formula fields. If S is already a
## LinearFormula, it is returned as-is.

if (nargin < 1)
return;
endif

if (isa (s, "LinearFormula"))
obj = s;
return;
endif

if (! isstruct (s))
error ("LinearFormula: constructor argument must be a struct.");
endif

if (isfield (s, "ResponseName"))
obj.ResponseName = s.ResponseName;
endif
if (isfield (s, "LinearPredictor"))
obj.LinearPredictor = s.LinearPredictor;
endif
if (isfield (s, "Terms"))
obj.Terms = s.Terms;
endif
if (isfield (s, "HasIntercept"))
obj.HasIntercept = s.HasIntercept;
endif
if (isfield (s, "InModel"))
obj.InModel = s.InModel;
endif
if (isfield (s, "CoefficientNames"))
obj.CoefficientNames = s.CoefficientNames;
endif
if (isfield (s, "PredictorNames"))
obj.PredictorNames = s.PredictorNames;
endif
if (isfield (s, "VariableNames"))
obj.VariableNames = s.VariableNames;
endif
endfunction

function disp (obj)
## disp Display only the formula string.
##
## Matches MATLAB's LinearFormula display behavior: shows only
## the human-readable formula (e.g., "y ~ 1 + x1 + x2").
fprintf (" %s ~ %s\n", obj.ResponseName, obj.LinearPredictor);
endfunction

function s = char (obj)
## char Convert to character representation.
s = sprintf ("%s ~ %s", obj.ResponseName, obj.LinearPredictor);
endfunction

endmethods

endclassdef
Loading