Skip to content

Commit 54fa5e2

Browse files
committed
Added extra output argument to bootlm to return a structure to reproduce the regression
The structure contains the: - Design matrix of the predictors - Regression coefficients - Hypothesis matrix (if relevant) - The outcome variable
1 parent 13e370e commit 54fa5e2

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

inst/bootlm.m

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
% -- Function File: [STATS, BOOTSTAT] = bootlm (...)
2424
% -- Function File: [STATS, BOOTSTAT, AOVSTAT] = bootlm (...)
2525
% -- Function File: [STATS, BOOTSTAT, AOVSTAT, PRED_ERR] = bootlm (...)
26+
% -- Function File: [STATS, BOOTSTAT, AOVSTAT, PRED_ERR, X] = bootlm (...)
2627
%
2728
% Fits a linear model with categorical and/or continuous predictors (i.e.
2829
% independent variables) on a continuous outcome (i.e. dependent variable)
@@ -479,7 +480,12 @@
479480
% installed and loaded, then these computations will be automatically
480481
% accelerated by parallel processing on platforms with multiple processors
481482
%
482-
% bootlm (version 2024.05.17)
483+
% '[STATS, BOOTSTAT, AOVSTAT, PRED_ERR, MAT] = bootlm (...)' also returns
484+
% a structure containing the design matrix of the predictors (X), the
485+
% regression coefficients (b), the hypothesis matrix (L) and the outcome (Y)
486+
% for the linear model.
487+
%
488+
% bootlm (version 2024.07.08)
483489
% Author: Andrew Charles Penn
484490
% https://www.researchgate.net/profile/Andrew_Penn/
485491
%
@@ -497,7 +503,7 @@
497503
% You should have received a copy of the GNU General Public License
498504
% along with this program. If not, see http://www.gnu.org/licenses/
499505

500-
function [STATS, BOOTSTAT, AOVSTAT, PRED_ERR] = bootlm (Y, GROUP, varargin)
506+
function [STATS, BOOTSTAT, AOVSTAT, PRED_ERR, MAT] = bootlm (Y, GROUP, varargin)
501507

502508
if (nargin < 2)
503509
error (cat (2, 'bootlm usage: ''bootlm (Y, GROUP)''; ', ...
@@ -1275,6 +1281,8 @@
12751281
else
12761282
STATS.prior = cat (2, PRIOR(pairs(:, 1)), PRIOR(pairs(:, 2)));
12771283
end
1284+
% Modifying the hypothesis matrix (L) to represent the desired tests
1285+
L = make_test_matrix (L, pairs); % In case it is requested
12781286
otherwise
12791287
error (cat (2, 'bootlm: unrecignised bootstrap method.', ...
12801288
' Use ''wild'' or ''bayesian''.'))
@@ -1377,6 +1385,11 @@
13771385
'CI_upper', 'pval', 'fpr', 'N', 'prior'});
13781386
end
13791387

1388+
% Create MAT return value
1389+
if (nargout > 4)
1390+
MAT = struct ('X', X, 'b', b, 'L', L, 'Y', Y);
1391+
end
1392+
13801393
% Print table of model coefficients and make figure of diagnostic plots
13811394
switch (lower (DISPLAY))
13821395

0 commit comments

Comments
 (0)