-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
295 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
UnusedCode/WIPsubfnConvertPathsToMatrix.m → FinalCode/ConvertPathsToMatrix.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
function BCaCI = CreateBCaCI(Results,BootStrap,JackKnife,Thresholds) | ||
% from the point estimate, the bootstrap and the jacknife results return | ||
% all of the bias-corrected, accelerated confidence intervals. | ||
|
||
% Therefore, the whatever bootstrap estimates are calculated this function | ||
% creates the BCa confidence intervals for it. | ||
|
||
% Find the parameters in the bootstrap | ||
FieldNames = fieldnames(BootStrap); | ||
|
||
Nthresh = length(Thresholds); | ||
NPaths = size(Results.Paths,1); | ||
% prepare the structure to hold all of the BCa confidence intervals | ||
BCaCI = {}; | ||
for i = 1:length(FieldNames) | ||
Value = getfield(Results,FieldNames{i}); | ||
if iscell(Value) | ||
BlankValue = zeros(numel(Results.Paths{1}),1,2,NPaths,Nthresh); | ||
else | ||
BlankValue = zeros([size(Value) 2 Nthresh]); | ||
end | ||
BCaCI = setfield(BCaCI,FieldNames{i},BlankValue); | ||
end | ||
%% put the confidence intervals into this structure | ||
% cycle over the input fieldnames | ||
for i = 1:length(FieldNames) | ||
if ~isempty(strmatch(FieldNames{i},'Paths')) | ||
CurrentBCaCI = zeros(size(getfield(BCaCI,FieldNames{i}))); | ||
% cycle over all the input thresholds | ||
for t = 1:Nthresh | ||
CurrentAlpha = Thresholds(t); | ||
for j = 1:NPaths | ||
% This takes that date from each path and flattens it | ||
BootStrapData = ConvertPathsToMatrix(BootStrap.Paths,j); | ||
JackKnifeData = ConvertPathsToMatrix(JackKnife.Paths,j); | ||
|
||
PointEstimate = reshape(Results.Paths{j},numel(Results.Paths{j}),1); | ||
|
||
% The flattended data allows it to be used by this | ||
% program which calculates the adjusted alpha limits used for | ||
% determining the confidence intervals | ||
[Alpha1 Alpha2 Z p] = CalculateBCaLimits(JackKnifeData,PointEstimate, BootStrapData,CurrentAlpha); | ||
|
||
% find the confidence intervals for these adjusted | ||
% alpha limits | ||
CurrentBCaCI(:,:,:,j,t) = CalculateBCaCI(BootStrapData,Alpha1,Alpha2,PointEstimate); | ||
end | ||
end | ||
% put the confidence interval data back into the structure | ||
% TO DO: somehow UNFLATTEN the data | ||
BCaCI = setfield(BCaCI,FieldNames{i},CurrentBCaCI); | ||
else | ||
CurrentBCaCI = zeros(size(getfield(BCaCI,FieldNames{i}))); | ||
for t = 1:Nthresh | ||
CurrentAlpha = Thresholds(t); | ||
BootStrapData = getfield(BootStrap,FieldNames{i}); | ||
JackKnifeData = getfield(JackKnife,FieldNames{i}); | ||
PointEstimate = getfield(Results,FieldNames{i}); | ||
[Alpha1 Alpha2 Z p] = CalculateBCaLimits(JackKnifeData,PointEstimate, BootStrapData,CurrentAlpha); | ||
|
||
% find the confidence intervals | ||
CurrentBCaCI(:,:,:,t) = CalculateBCaCI(BootStrapData,Alpha1,Alpha2,PointEstimate); | ||
end | ||
BCaCI = setfield(BCaCI,FieldNames{i},CurrentBCaCI); | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.