Skip to content

Commit

Permalink
minor bug fix
Browse files Browse the repository at this point in the history
fixed bug in `bootlm` causing an error if missing observations (NaN, in either the outcome or any of the continuous predictors) caused a group to be excluded. Note that missing values are not acceptable in grouping variables of categorical predictors.
  • Loading branch information
acp29 committed Jan 19, 2024
1 parent a60e228 commit fb8704b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 18 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: statistics-resampling
version: 5.5.5
date: 2024-01-18
version: 5.5.5.1
date: 2024-01-19
author: Andrew Penn <[email protected]>
maintainer: Andrew Penn <[email protected]>
title: A statistics package with a variety of resampling tools
Expand Down
29 changes: 15 additions & 14 deletions inst/bootlm.m
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,21 @@
end
end

% Remove NaN or non-finite observations in y or any continuous predictors
% NaN is not tolerated in grouping variables for categorical predictors
if (isempty (GROUP))
excl = any ([isnan(Y), isinf(Y)], 2);
else
XC = GROUP(:,CONTINUOUS);
if iscell(XC)
XC = cell2mat (XC);
end
excl = any ([isnan(Y), isinf(Y), any(isnan(XC),2), any(isinf(XC),2)], 2);
GROUP(excl,:) = [];
end
Y(excl) = [];
n = numel (Y); % Recalculate total number of observations

% Create unique numeric group identifiers for levels of categorical
% and extract levels of each categorical predictor
GROUPID = zeros (n, K);
Expand Down Expand Up @@ -719,20 +734,6 @@
CONTRASTS(~ contr_sum_to_zero) = {'anova'};
end

% Remove NaN or non-finite observations
if (isempty (GROUP))
excl = any ([isnan(Y), isinf(Y)], 2);
else
XC = GROUP(:,CONTINUOUS);
if iscell(XC)
XC = cell2mat (XC);
end
excl = any ([isnan(Y), isinf(Y), any(isnan(XC),2), any(isinf(XC),2)], 2);
GROUP(excl,:) = [];
end
Y(excl) = [];
n = numel (Y); % Recalculate total number of observations

% Evaluate model type input argument and create terms matrix if not provided
msg = cat (2, 'bootlm: the number of columns in the term definitions', ...
' cannot exceed the number of columns of GROUP');
Expand Down
Binary file modified matlab/statistics-resampling.mltbx
Binary file not shown.
4 changes: 2 additions & 2 deletions matlab/statistics-resampling.prj
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<deployment-project plugin="plugin.toolbox" plugin-version="1.0">
<configuration build-checksum="2919770292" file="Y:\Documents\GitHub\statistics-resampling\matlab\statistics-resampling.prj" location="Y:\Documents\GitHub\statistics-resampling\matlab" name="statistics-resampling" target="target.toolbox" target-name="Package Toolbox">
<configuration build-checksum="3590304514" file="Y:\Documents\GitHub\statistics-resampling\matlab\statistics-resampling.prj" location="Y:\Documents\GitHub\statistics-resampling\matlab" name="statistics-resampling" target="target.toolbox" target-name="Package Toolbox">
<param.appname>statistics-resampling</param.appname>
<param.authnamewatermark>Andrew Penn</param.authnamewatermark>
<param.email>[email protected]</param.email>
<param.company>University of Sussex, UK</param.company>
<param.summary>Statistical analysis using resampling methods</param.summary>
<param.description>The statistics-resampling package is an Octave package and Matlab toolbox that can be used to overcome a wide variety of statistics problems using non-parametric resampling methods. In particular, the functions included can be used to estimate bias, uncertainty (standard errors and confidence intervals), prediction error, and test hypotheses (p-values). Variations of the resampling methods are included that improve the accuracy of the statistics for small samples and samples with complex dependence structures.</param.description>
<param.screenshot>Y:\Documents\GitHub\statistics-resampling\doc\icon.png</param.screenshot>
<param.version>5.5.5</param.version>
<param.version>5.5.5.1</param.version>
<param.output>${PROJECT_ROOT}\statistics-resampling.mltbx</param.output>
<param.products.name />
<param.products.id />
Expand Down

0 comments on commit fb8704b

Please sign in to comment.