R: Calculate BCa from vector of bootstrapped resultsHow can I use pre bootstrapped data to obtain a BCa confidence interval?adjusted bootstrap confidence intervals (BCa) with parametric bootstrap in boot packagebootstrap proportion confidence intervalBootstrapping confidence intervals in R: BCa method and prescribed resamplesConfidence Interval from hierarchical bootstrapCalculating 95% confidence intervals in quantile regression in R using rq functionHow can I use pre bootstrapped data to obtain a BCa confidence interval?Bootstrapping a vector of results, by group in RHow to add bootstrap CI into this function in RR: boot.ci - does type=“basic” provide the correct confidence interval end points?BCa confidence interval using pre-bootstrapped data
Do things made of adamantine rust?
Find missing number in the transformation
BASH script: How to assign each line of command output to values in an array?
Where does an unaligned creature's soul go after death?
Resolving moral conflict
Cut a cake into 3 equal portions with only a knife
How do I deal with too many NPCs in my campaign?
Should I complain to HR about being mocked for request I made
Worms crawling under skin
delete object network in cisco ASA with packet tracert
Why does NASA publish all the results/data it gets?
What are these pixel-level discolored specks? How can I fix it?
As an employer, can I compel my employees to vote?
Algorithm that spans orthogonal vectors: Python
Will Proving or Disproving of any of the following have effects on Chemistry in general?
Would Taiwan and China's dispute be solved if Taiwan gave up being the Republic of China?
Performance for simple code that converts a RGB tuple to hex string
What benefits does the Power Word Kill spell have?
How does IBM's 53-bit quantum computer compare to classical ones for cryptanalytic tasks?
Where Does VDD+0.3V Input Limit Come From on IC chips?
Can this word order be rearranged?
What is the meaning of "heutig" in this sentence?
Do the villains know Batman has no superpowers?
Hiking with a mule or two?
R: Calculate BCa from vector of bootstrapped results
How can I use pre bootstrapped data to obtain a BCa confidence interval?adjusted bootstrap confidence intervals (BCa) with parametric bootstrap in boot packagebootstrap proportion confidence intervalBootstrapping confidence intervals in R: BCa method and prescribed resamplesConfidence Interval from hierarchical bootstrapCalculating 95% confidence intervals in quantile regression in R using rq functionHow can I use pre bootstrapped data to obtain a BCa confidence interval?Bootstrapping a vector of results, by group in RHow to add bootstrap CI into this function in RR: boot.ci - does type=“basic” provide the correct confidence interval end points?BCa confidence interval using pre-bootstrapped data
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I am looking for a way to calculate bias-corrected accelerated confidence intervals in R using a vector of bootstrapped results (which are bootstrap estimates of population growth rate - lambda). However, the packages I find are either made to use specific object types (as in the "boot" package) or do not calculate BCa type confidence intervals. The reason I have bootstrapped the results using a for loop and then stored the results in a vector is that for each bootstrap resample I first get a 80 x 33 matrix of results which defines parameters for each population in each year of sampling, which in turn define lambda for each population. As far as I can tell this would be cumbersome in the boot package and was easy to program as a for loop. The actual set of functions is rather complex and cannot be included here.
I did try using this question as a guide to fake a "boot" object, but it did not work: How can I use pre bootstrapped data to obtain a BCa confidence interval?.
Lets say I have my observed estimate of lambda
lambda = 1.18
and that we simulate a vector of bootstrapped estimates
library(fGarch)
lambdaBS = rsnorm(999,mean=lambda-0.04,sd=0.11,xi=2.5)
plot(density(lambdaBS))
which is right skewed and biased.
I am hoping that, using this information, there is a currently existing function which calculates BCa confidence intervals or else that it is easy to program a function to do so. As of yet, I have not found this to be the case.
r confidence-interval statistics-bootstrap
add a comment
|
I am looking for a way to calculate bias-corrected accelerated confidence intervals in R using a vector of bootstrapped results (which are bootstrap estimates of population growth rate - lambda). However, the packages I find are either made to use specific object types (as in the "boot" package) or do not calculate BCa type confidence intervals. The reason I have bootstrapped the results using a for loop and then stored the results in a vector is that for each bootstrap resample I first get a 80 x 33 matrix of results which defines parameters for each population in each year of sampling, which in turn define lambda for each population. As far as I can tell this would be cumbersome in the boot package and was easy to program as a for loop. The actual set of functions is rather complex and cannot be included here.
I did try using this question as a guide to fake a "boot" object, but it did not work: How can I use pre bootstrapped data to obtain a BCa confidence interval?.
Lets say I have my observed estimate of lambda
lambda = 1.18
and that we simulate a vector of bootstrapped estimates
library(fGarch)
lambdaBS = rsnorm(999,mean=lambda-0.04,sd=0.11,xi=2.5)
plot(density(lambdaBS))
which is right skewed and biased.
I am hoping that, using this information, there is a currently existing function which calculates BCa confidence intervals or else that it is easy to program a function to do so. As of yet, I have not found this to be the case.
r confidence-interval statistics-bootstrap
add a comment
|
I am looking for a way to calculate bias-corrected accelerated confidence intervals in R using a vector of bootstrapped results (which are bootstrap estimates of population growth rate - lambda). However, the packages I find are either made to use specific object types (as in the "boot" package) or do not calculate BCa type confidence intervals. The reason I have bootstrapped the results using a for loop and then stored the results in a vector is that for each bootstrap resample I first get a 80 x 33 matrix of results which defines parameters for each population in each year of sampling, which in turn define lambda for each population. As far as I can tell this would be cumbersome in the boot package and was easy to program as a for loop. The actual set of functions is rather complex and cannot be included here.
I did try using this question as a guide to fake a "boot" object, but it did not work: How can I use pre bootstrapped data to obtain a BCa confidence interval?.
Lets say I have my observed estimate of lambda
lambda = 1.18
and that we simulate a vector of bootstrapped estimates
library(fGarch)
lambdaBS = rsnorm(999,mean=lambda-0.04,sd=0.11,xi=2.5)
plot(density(lambdaBS))
which is right skewed and biased.
I am hoping that, using this information, there is a currently existing function which calculates BCa confidence intervals or else that it is easy to program a function to do so. As of yet, I have not found this to be the case.
r confidence-interval statistics-bootstrap
I am looking for a way to calculate bias-corrected accelerated confidence intervals in R using a vector of bootstrapped results (which are bootstrap estimates of population growth rate - lambda). However, the packages I find are either made to use specific object types (as in the "boot" package) or do not calculate BCa type confidence intervals. The reason I have bootstrapped the results using a for loop and then stored the results in a vector is that for each bootstrap resample I first get a 80 x 33 matrix of results which defines parameters for each population in each year of sampling, which in turn define lambda for each population. As far as I can tell this would be cumbersome in the boot package and was easy to program as a for loop. The actual set of functions is rather complex and cannot be included here.
I did try using this question as a guide to fake a "boot" object, but it did not work: How can I use pre bootstrapped data to obtain a BCa confidence interval?.
Lets say I have my observed estimate of lambda
lambda = 1.18
and that we simulate a vector of bootstrapped estimates
library(fGarch)
lambdaBS = rsnorm(999,mean=lambda-0.04,sd=0.11,xi=2.5)
plot(density(lambdaBS))
which is right skewed and biased.
I am hoping that, using this information, there is a currently existing function which calculates BCa confidence intervals or else that it is easy to program a function to do so. As of yet, I have not found this to be the case.
r confidence-interval statistics-bootstrap
r confidence-interval statistics-bootstrap
asked Mar 28 at 15:39
ndellndell
112 bronze badges
112 bronze badges
add a comment
|
add a comment
|
1 Answer
1
active
oldest
votes
As would be the case with R, where certain utilities are spread far and wide between packages, there was an easy solution, but it took me hours of searching to find, so I will answer my own question for anyone who may be searching for something similar.
Using the example data in the question, the bca function in the "coxed" R package give bias-corrected and accelerated confidence intervals for a vector of bootstrapped results. And we can compare them to other confidence intervals.
library(fGarch)
library(coxed)
set.seed(15438)
#simulate bootstrap statistics
lambdaBS = rsnorm(9999,mean=lambda-0.04,sd=0.11,xi=2.5)
#bias-corrected and accelerated
bca(lambdaBS)
1.002437 1.452525
#confidence intervals using standard error (inappropriate)
c(lambda-(sd(lambdaBS)*2),lambda+(sd(lambdaBS)*2))
0.9599789 1.4000211
#percentile confidence intervals
quantile(lambdaBS, c(0.025,0.975))
2.5% 97.5%
0.9895892 1.4016528
This seems to work well. I am unsure of how it corrects for bias without requiring the initial estimate of the statistic in question, but have not read the paper this method is based on, yet.
Another simulation shows how this compares to results using boot and boot.ci.
library(boot)
#generate data
set.seed(12345)
dat = rsnorm(500,mean=1.6,sd=0.5,xi=3.0)
#bootstrap the median
meanfun = function(x,id) mean(x[id])
test = boot(data=dat,R=999,statistic=meanfun)
#BCa using boot.ci
boot.ci(test,type="bca")
BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
Based on 999 bootstrap replicates
CALL :
boot.ci(boot.out = test, type = "bca")
Intervals :
Level BCa
95% ( 1.537, 1.626 )
Calculations and Intervals on Original Scale
#BCa using bca function from coxed package
bca(test$t)
1.536888 1.625524
And in this case both functions give identical results.
add a comment
|
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55401615%2fr-calculate-bca-from-vector-of-bootstrapped-results%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
As would be the case with R, where certain utilities are spread far and wide between packages, there was an easy solution, but it took me hours of searching to find, so I will answer my own question for anyone who may be searching for something similar.
Using the example data in the question, the bca function in the "coxed" R package give bias-corrected and accelerated confidence intervals for a vector of bootstrapped results. And we can compare them to other confidence intervals.
library(fGarch)
library(coxed)
set.seed(15438)
#simulate bootstrap statistics
lambdaBS = rsnorm(9999,mean=lambda-0.04,sd=0.11,xi=2.5)
#bias-corrected and accelerated
bca(lambdaBS)
1.002437 1.452525
#confidence intervals using standard error (inappropriate)
c(lambda-(sd(lambdaBS)*2),lambda+(sd(lambdaBS)*2))
0.9599789 1.4000211
#percentile confidence intervals
quantile(lambdaBS, c(0.025,0.975))
2.5% 97.5%
0.9895892 1.4016528
This seems to work well. I am unsure of how it corrects for bias without requiring the initial estimate of the statistic in question, but have not read the paper this method is based on, yet.
Another simulation shows how this compares to results using boot and boot.ci.
library(boot)
#generate data
set.seed(12345)
dat = rsnorm(500,mean=1.6,sd=0.5,xi=3.0)
#bootstrap the median
meanfun = function(x,id) mean(x[id])
test = boot(data=dat,R=999,statistic=meanfun)
#BCa using boot.ci
boot.ci(test,type="bca")
BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
Based on 999 bootstrap replicates
CALL :
boot.ci(boot.out = test, type = "bca")
Intervals :
Level BCa
95% ( 1.537, 1.626 )
Calculations and Intervals on Original Scale
#BCa using bca function from coxed package
bca(test$t)
1.536888 1.625524
And in this case both functions give identical results.
add a comment
|
As would be the case with R, where certain utilities are spread far and wide between packages, there was an easy solution, but it took me hours of searching to find, so I will answer my own question for anyone who may be searching for something similar.
Using the example data in the question, the bca function in the "coxed" R package give bias-corrected and accelerated confidence intervals for a vector of bootstrapped results. And we can compare them to other confidence intervals.
library(fGarch)
library(coxed)
set.seed(15438)
#simulate bootstrap statistics
lambdaBS = rsnorm(9999,mean=lambda-0.04,sd=0.11,xi=2.5)
#bias-corrected and accelerated
bca(lambdaBS)
1.002437 1.452525
#confidence intervals using standard error (inappropriate)
c(lambda-(sd(lambdaBS)*2),lambda+(sd(lambdaBS)*2))
0.9599789 1.4000211
#percentile confidence intervals
quantile(lambdaBS, c(0.025,0.975))
2.5% 97.5%
0.9895892 1.4016528
This seems to work well. I am unsure of how it corrects for bias without requiring the initial estimate of the statistic in question, but have not read the paper this method is based on, yet.
Another simulation shows how this compares to results using boot and boot.ci.
library(boot)
#generate data
set.seed(12345)
dat = rsnorm(500,mean=1.6,sd=0.5,xi=3.0)
#bootstrap the median
meanfun = function(x,id) mean(x[id])
test = boot(data=dat,R=999,statistic=meanfun)
#BCa using boot.ci
boot.ci(test,type="bca")
BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
Based on 999 bootstrap replicates
CALL :
boot.ci(boot.out = test, type = "bca")
Intervals :
Level BCa
95% ( 1.537, 1.626 )
Calculations and Intervals on Original Scale
#BCa using bca function from coxed package
bca(test$t)
1.536888 1.625524
And in this case both functions give identical results.
add a comment
|
As would be the case with R, where certain utilities are spread far and wide between packages, there was an easy solution, but it took me hours of searching to find, so I will answer my own question for anyone who may be searching for something similar.
Using the example data in the question, the bca function in the "coxed" R package give bias-corrected and accelerated confidence intervals for a vector of bootstrapped results. And we can compare them to other confidence intervals.
library(fGarch)
library(coxed)
set.seed(15438)
#simulate bootstrap statistics
lambdaBS = rsnorm(9999,mean=lambda-0.04,sd=0.11,xi=2.5)
#bias-corrected and accelerated
bca(lambdaBS)
1.002437 1.452525
#confidence intervals using standard error (inappropriate)
c(lambda-(sd(lambdaBS)*2),lambda+(sd(lambdaBS)*2))
0.9599789 1.4000211
#percentile confidence intervals
quantile(lambdaBS, c(0.025,0.975))
2.5% 97.5%
0.9895892 1.4016528
This seems to work well. I am unsure of how it corrects for bias without requiring the initial estimate of the statistic in question, but have not read the paper this method is based on, yet.
Another simulation shows how this compares to results using boot and boot.ci.
library(boot)
#generate data
set.seed(12345)
dat = rsnorm(500,mean=1.6,sd=0.5,xi=3.0)
#bootstrap the median
meanfun = function(x,id) mean(x[id])
test = boot(data=dat,R=999,statistic=meanfun)
#BCa using boot.ci
boot.ci(test,type="bca")
BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
Based on 999 bootstrap replicates
CALL :
boot.ci(boot.out = test, type = "bca")
Intervals :
Level BCa
95% ( 1.537, 1.626 )
Calculations and Intervals on Original Scale
#BCa using bca function from coxed package
bca(test$t)
1.536888 1.625524
And in this case both functions give identical results.
As would be the case with R, where certain utilities are spread far and wide between packages, there was an easy solution, but it took me hours of searching to find, so I will answer my own question for anyone who may be searching for something similar.
Using the example data in the question, the bca function in the "coxed" R package give bias-corrected and accelerated confidence intervals for a vector of bootstrapped results. And we can compare them to other confidence intervals.
library(fGarch)
library(coxed)
set.seed(15438)
#simulate bootstrap statistics
lambdaBS = rsnorm(9999,mean=lambda-0.04,sd=0.11,xi=2.5)
#bias-corrected and accelerated
bca(lambdaBS)
1.002437 1.452525
#confidence intervals using standard error (inappropriate)
c(lambda-(sd(lambdaBS)*2),lambda+(sd(lambdaBS)*2))
0.9599789 1.4000211
#percentile confidence intervals
quantile(lambdaBS, c(0.025,0.975))
2.5% 97.5%
0.9895892 1.4016528
This seems to work well. I am unsure of how it corrects for bias without requiring the initial estimate of the statistic in question, but have not read the paper this method is based on, yet.
Another simulation shows how this compares to results using boot and boot.ci.
library(boot)
#generate data
set.seed(12345)
dat = rsnorm(500,mean=1.6,sd=0.5,xi=3.0)
#bootstrap the median
meanfun = function(x,id) mean(x[id])
test = boot(data=dat,R=999,statistic=meanfun)
#BCa using boot.ci
boot.ci(test,type="bca")
BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
Based on 999 bootstrap replicates
CALL :
boot.ci(boot.out = test, type = "bca")
Intervals :
Level BCa
95% ( 1.537, 1.626 )
Calculations and Intervals on Original Scale
#BCa using bca function from coxed package
bca(test$t)
1.536888 1.625524
And in this case both functions give identical results.
edited Mar 29 at 16:20
answered Mar 29 at 16:12
ndellndell
112 bronze badges
112 bronze badges
add a comment
|
add a comment
|
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55401615%2fr-calculate-bca-from-vector-of-bootstrapped-results%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown