Confidence intervall of quantil
8 views (last 30 days)
Show older comments
Hi, I am trying to find the 95% confidence interval for my 99% quantile. I am using the 3 parameter Weibull distribution to get the quantile. Now I am trying to get the confidence interval. I have read that it is possible to get it with an anonymous function and with bootci while giving the data as input and getting the quantil as output. Unfortunately, I do not know how exactly this works.
clear all
close all
clc;
C = wblrnd(3,1:100)
custompdf = @(x,a,b,c) (x>c).*(b/a).*(((x-c)/a).^(b-1)).*exp(-((x-c)/a).^b);
customcdf = @(x,a,b,c) (x>c).*1-exp(-((x-c)/a).^b);
opt = statset('MaxIter',1e5,'MaxFunEvals',1e5,'FunValCheck','off');
params = mle(C,'pdf',custompdf,'start',[mean(C) mean(C) min(C)/max(C)],'Options',opt,'LowerBound',[0 0 -Inf],'UpperBound',[Inf Inf min(C)]);
a_parameter = params(1,1);
b_parameter = params(1,2);
c_parameter = params(1,3);
x = [c_parameter+eps(c_parameter):0.1:max(C)*1.5];
quantile_Weibull3 = fsolve(@(x) customcdf(x, a_parameter, b_parameter, c_parameter) - 0.99, mean(C));
1 Comment
Jeff Miller
on 2 Jun 2023
Why do you start by generating random values for C? Normally a confidence interval is generated from some specific set of observed data values, so generating them randomly is confusing. Possibly I just don't understand the question...
Answers (1)
Prathamesh
on 16 Aug 2023
Hi,
I understand that you want to know how the code works and how to find 95% confidence interval for your 99% quantile.
Pointers to explain the code and confidence interval calculation:
- Random data samples are generated from a Weibull distribution and PDF and CDF are defined for a three-parameter Weibull distribution.
- Options for MLE estimation are set specifying the maximum number of iterations and function evaluations and disables the check for valid function values.
- Parameters of the three-parameter Weibull distribution are estimated using MLE and are extracted from “params” array.
- Then the “fsolve” function is used to find the value of x for which the CDF equals 0.99. This corresponds to the quantile for a cumulative probability of 0.99 and the quantile is acquired.
- Now you can use “bootci” function to calculate 95% bootstrap confidence interval.
nboot = 1000;
bootfcn = @(x) quantile(x, 0.99);
ci = bootci(nboot, bootfcn, data);
To get more information about working of “bootci” function and how the confidence interval is calculated for different functions refer to the documentation attached below.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!