Skip to content

Commit a9b2d6a

Browse files
committed
bootridge: Add calculation of predicted R-squared
1 parent f6c4d57 commit a9b2d6a

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

‎inst/bootridge.m‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,14 @@
233233
%
234234
% o pred_err
235235
% The minimized prediction error calculated using the optimal lambda.
236-
% Note that pred_err calculation is based on the outcome variables
237-
% (columns) in Y after internal standardization, and the predictors
238-
% X after internal centering.
236+
% Note that pred_err calculation is summed over outcome variables
237+
% (columns) from the fit on Y (after internal standardization), using
238+
% the predictors X (after internal centering).
239+
%
240+
% o RSQ_pred
241+
% The predicted R-squared for the fit across all the outcomes.
242+
% RSQ_pred (average) = 1 - (S.pred_err / q),
243+
% where q is the number of outcomes.
239244
%
240245
% o stability
241246
% The probabilities that the sign of the regression coefficients
@@ -754,6 +759,9 @@
754759
[pred_err, stability, oob_err] = booterr632 (YS, XC, lambda, P_vec, B, ...
755760
categor, seed);
756761

762+
% Compute the predicted R^2 averaged across outcomes
763+
RSQ_pred = 1 - pred_err / q;
764+
757765
% Correct stability selection probabilities for the design effect
758766
stdnormcdf = @(x) 0.5 * (1 + erf (x / sqrt (2)));
759767
stdnorminv = @(p) sqrt (2) * erfinv (2 * p - 1);
@@ -995,6 +1003,7 @@
9951003
S.tol = tol;
9961004
S.iter = iter;
9971005
S.pred_err = pred_err;
1006+
S.RSQ_pred = RSQ_pred;
9981007
S.stability = stability;
9991008
if (q > 1); S.RTAB = RTAB; end
10001009
S.P_vec = P_vec;

0 commit comments

Comments
 (0)