I have 567 unique customer ID with their Trips and Cumulative Trips. I want to get 10%, 20%, 30% customer sample by Bootstrap simulation. I also want to see the normal distribution for 10%, 20%, and 10% sample mean. As I am new in R and did not do it previously, so your help is appreciated
10% sampling (57 Sample)
set.seed(4123)
CI.trips=c(new.col.allc$n)
mean <‐ mean(CI.trips)
mean
N <‐ 57
nboots <‐ 1000
boot.result <‐ numeric(nboots)
for(i in 1:nboots)
{
boot.samp <‐ sample(CI.trips, N, replace=FALSE)
boot.result[i] <‐ mean(boot.samp)
}
print(boot.samp)
hist(boot.result)
print(boot.result)
I am getting the following outputs
> set.seed(4123)
> CI.trips=c(new.col.allc$n)
> mean <‐ mean(CI.trips)
> mean
[1] 45.49206
> N <‐ 57
> nboots <‐ 1000
> boot.result <‐ numeric(nboots)
> for(i in 1:nboots)
+ {
+ boot.samp <‐ sample(CI.trips, N, replace=FALSE)
+ boot.result[i] <‐ mean(boot.samp)
+ }
> print(boot.samp)
[1] 15 11 3 6 6 81 1 14 2 7 10 2 28 153 1 15 46 1 2 246 118 223 2 38 28 32 24 12 5
[30] 86 402 106 1 16 1 29 6 6 5 10 6 22 56 34 7 299 112 122 27 31 307 2 2 27 4 136 20
> hist(boot.result)