How to bootstrap estimated Gamma parameters from sample 95% confidence
7 次查看(过去 30 天)
显示 更早的评论
I've got a question I'm stuck on. I've attached the question below.
I have estimated the parameters alpha and beta (a and b) from question (b) using the method of moments, I am stuck on question (d).
I understand the general concept of bootstrapping (resampling data with replacement then reevaluating parameters) but I am confused about how to apply this, and how to determine a 95% confidence level.
I am using MATLAB. Any help is appreciated.
size(cow1) % checking size of cow1, document states 60 days but only 50 entries so will work off this.
mu_1 = mean(cow1) % mean of cow1 sample
mu_2 = mean(cow2) % mean of cow2 sample
mu_avg = ((mu_2+mu_1)/2)*0.05 % average of the two means to 5% significance
% difference between average of means to 5% significance and the difference in the sample means is negative
mu_avg - (mu_2 - mu_1) % this implies that the samples are not drawn from the same distribution
h=kstest2(cow1,cow2) % application of two-sample kolmogorov-smirnov test to further conclude that samples are not from same distribution
X = cat(2,cow1,cow2) % concatenate cow1 and cow2
mu_X = mean(X) % mean of concatenated array
i=1:100;
mu_X2 = sum((X(i)-mu_X).^2) % calculating necessary property for method of moments
alpha = (100*(mu_X)^2)/(mu_X2) % first parameter alpha using method of moments
theta = (1/(100*mu_X))*mu_X2 % second parameter theta using method of moments
gamfit(X) % using gamfit to check plausibility of estimated parameters
pd_gamma = makedist('Gamma','a',alpha,'b',theta)
Thanks in advance
0 个评论
回答(1 个)
Jeff Miller
2020-9-4
Generate 1000 (say) bootstrap samples from X.
For each sample, compute the parameter estimates, so in the end you have 1000 estimated values for each parameter.
Now look at a frequency distribution of the 1000 estimates for alpha. The middle 95% of this distribution defines the range of the 95% confidence interval for alpha. Analogously for the other parameter?
2 个评论
Jeff Miller
2020-9-5
Well, I'd rather not do the assignment for you. But you can get a lot of help looking at the second example here: Bootstrapping Multiple Statistics. You need to make a function that computes alpha and theta for any given bootstrap sample, call it MyFun. You already have essentially the lines to do that:
alpha = (100*(mu_X)^2)/(mu_X2) % first parameter alpha using method of moments
theta = (1/(100*mu_X))*mu_X2 % second parameter theta using method of moments
so just wrap them in a function that gets X passed to it. Once you have that function, use this command to generate 1000 estimates of each parameter.
stats = bootstrp(1000,@MyFun,X);
Note that the bootstrp function is doing a lot of the hard work for you--generating all the bootstrap samples and accumulating the different values that you return from MyFun. At the end, stats will be an array with 1000 rows and 2 columns (or maybe vice versa) with the different parameter estimates generated by the bootstrapping process
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spectral Measurements 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!