Skip to content

Commit

Permalink
Added extra output argument to bootlm to return a structure to reprod…
Browse files Browse the repository at this point in the history
…uce the regression

The structure contains the:
- Design matrix of the predictors
- Regression coefficients
- Hypothesis matrix (if relevant)
- The outcome variable
  • Loading branch information
acpennlab committed Jul 8, 2024
1 parent 13e370e commit 54fa5e2
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions inst/bootlm.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
% -- Function File: [STATS, BOOTSTAT] = bootlm (...)
% -- Function File: [STATS, BOOTSTAT, AOVSTAT] = bootlm (...)
% -- Function File: [STATS, BOOTSTAT, AOVSTAT, PRED_ERR] = bootlm (...)
% -- Function File: [STATS, BOOTSTAT, AOVSTAT, PRED_ERR, X] = bootlm (...)
%
% Fits a linear model with categorical and/or continuous predictors (i.e.
% independent variables) on a continuous outcome (i.e. dependent variable)
Expand Down Expand Up @@ -479,7 +480,12 @@
% installed and loaded, then these computations will be automatically
% accelerated by parallel processing on platforms with multiple processors
%
% bootlm (version 2024.05.17)
% '[STATS, BOOTSTAT, AOVSTAT, PRED_ERR, MAT] = bootlm (...)' also returns
% a structure containing the design matrix of the predictors (X), the
% regression coefficients (b), the hypothesis matrix (L) and the outcome (Y)
% for the linear model.
%
% bootlm (version 2024.07.08)
% Author: Andrew Charles Penn
% https://www.researchgate.net/profile/Andrew_Penn/
%
Expand All @@ -497,7 +503,7 @@
% You should have received a copy of the GNU General Public License
% along with this program. If not, see http://www.gnu.org/licenses/

function [STATS, BOOTSTAT, AOVSTAT, PRED_ERR] = bootlm (Y, GROUP, varargin)
function [STATS, BOOTSTAT, AOVSTAT, PRED_ERR, MAT] = bootlm (Y, GROUP, varargin)

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

% Create MAT return value
if (nargout > 4)
MAT = struct ('X', X, 'b', b, 'L', L, 'Y', Y);
end

% Print table of model coefficients and make figure of diagnostic plots
switch (lower (DISPLAY))

Expand Down

0 comments on commit 54fa5e2

Please sign in to comment.