statistics-bootstrap

GPU computing for bootstrapping using “boot” package

寵の児 提交于 2021-02-18 17:11:32
问题 I would like to do a large analysis using bootstrapping. I saw that the speed of bootstrapping is increased using parallel computing as in the following code: Parallel computing # detect number of cpu library(parallel) detectCores() library(boot) # boot function --> mean bt.mean <- function(dat, d){ x <- dat[d] m <- mean(x) return(m) } # obtain confidence intervals # use parallel computing with 4 cpus x <- mtcars$mpg bt <- boot(x, bt.mean, R = 1000, parallel = "snow", ncpus = 4) quantile(bt$t

GPU computing for bootstrapping using “boot” package

倾然丶 夕夏残阳落幕 提交于 2021-02-18 17:10:17
问题 I would like to do a large analysis using bootstrapping. I saw that the speed of bootstrapping is increased using parallel computing as in the following code: Parallel computing # detect number of cpu library(parallel) detectCores() library(boot) # boot function --> mean bt.mean <- function(dat, d){ x <- dat[d] m <- mean(x) return(m) } # obtain confidence intervals # use parallel computing with 4 cpus x <- mtcars$mpg bt <- boot(x, bt.mean, R = 1000, parallel = "snow", ncpus = 4) quantile(bt$t

GPU computing for bootstrapping using “boot” package

生来就可爱ヽ(ⅴ<●) 提交于 2021-02-18 17:09:24
问题 I would like to do a large analysis using bootstrapping. I saw that the speed of bootstrapping is increased using parallel computing as in the following code: Parallel computing # detect number of cpu library(parallel) detectCores() library(boot) # boot function --> mean bt.mean <- function(dat, d){ x <- dat[d] m <- mean(x) return(m) } # obtain confidence intervals # use parallel computing with 4 cpus x <- mtcars$mpg bt <- boot(x, bt.mean, R = 1000, parallel = "snow", ncpus = 4) quantile(bt$t

Manually bootstrapping linear regression in R

早过忘川 提交于 2021-02-10 11:53:05
问题 |Hi guys, I am asking you for help as I am stucked with bootstrapping... The task is: Use the nonparametric bootstrap to compute bootstrap standard error of CAPM beta estimate based on 1000 bootstrap replications and bootstrap sample size equal to the size of the original sample. If I understand it correctly, I am supposed to run my regression model 1000 times to estimate different estimates of the beta and its standard error. However, I am not able to put my thoughts into an actual R code.

Manually bootstrapping linear regression in R

匆匆过客 提交于 2021-02-10 11:49:14
问题 |Hi guys, I am asking you for help as I am stucked with bootstrapping... The task is: Use the nonparametric bootstrap to compute bootstrap standard error of CAPM beta estimate based on 1000 bootstrap replications and bootstrap sample size equal to the size of the original sample. If I understand it correctly, I am supposed to run my regression model 1000 times to estimate different estimates of the beta and its standard error. However, I am not able to put my thoughts into an actual R code.

Manually bootstrapping linear regression in R

十年热恋 提交于 2021-02-10 11:49:11
问题 |Hi guys, I am asking you for help as I am stucked with bootstrapping... The task is: Use the nonparametric bootstrap to compute bootstrap standard error of CAPM beta estimate based on 1000 bootstrap replications and bootstrap sample size equal to the size of the original sample. If I understand it correctly, I am supposed to run my regression model 1000 times to estimate different estimates of the beta and its standard error. However, I am not able to put my thoughts into an actual R code.

How to repeat a block of code to sample 2 values in r?

百般思念 提交于 2021-02-05 11:28:07
问题 (I'm new to this so now editing my question as a reproducible example). I've reviewed bootstrapping,loop and replicate functions and can't figure out how to repeat a series of steps (not just a single function) in R and store the result in dataframe. I need to randomly select 2 values from a pool of 22 values, 9 times. Then conduct a spearman rank correlation test on that dataset (2 columns, 9 rows) 10,000 times and store the value of each of those iterations. So I need to repeat these steps

R - bootstrapping with control for age and gender

久未见 提交于 2021-01-29 08:19:34
问题 I have a very unbalanced dataset ,, thousands of healthy participants and 21 patients (16 male and 5 female) ,, I want to use bootstrapping to define a new sampler but with control of age and gender. this is the method i'm using parametric_bootstrap_boot <- function(x) { # Perform bootstrap using boot package # Estimate mean mu <- boot(x, samplemean, R=1000)$t0 #Estimate sd sd <- boot(x, samplesd, R=1000)$t0 # Sample 21 observations set.seed(1) samples <- rnorm(21,mu,sd) return(samples) } how

Using tryCatch() to catch a bootstrap loop

强颜欢笑 提交于 2021-01-28 05:03:49
问题 I have insufficient knolwedge on the use of tryCatch() but have found it hard to find a good solution in the ongoing discussions. I have a self-programmed function which returns an object. It is actually a list object, but for simplicity assume it is a scalar. I am using a for() loop to bootstrap this function. My loop is of the following form: boot<-1000 for(i in 1:boot){ bootstrap_data<-data[sample(nrow(data),nrow(data),replace=T),] out[i]<-myfunction(bootstrap_data,X,...) } myfunction()

Problems with accessing double elements in a list in R

寵の児 提交于 2020-11-29 19:20:35
问题 I have performed a bootstrapping with 2.000 resamples of the Lee Carter model for mortality projection. The question is not specific for mortality studies, but on more general dimensions in R. After performing the bootstrapping I get a list with 2000 elements, each for every of 2.000 re-estimations of the model. For each model, there are estimates of my 3 variables: a_x, b_x and k_t. Both a_x and b_x are age-specific, so the "x" denotes an age in the interval [0:95]. I would now like to plot