| |||||||||||||||||
![]() |
![]() |
![]() |
|||||||||||||||
|
Bootstrap Statistics for Mean By Lyra Filiola
This section of tutorial will demostrate how you can easilly use bootstrap method to estimate the accuracy of mean or arithmetic average. Bootstrap method will be used in estimating the standard error, bias, and confidence interval of the mean statistic . Histogram of the mean will also be shown. The script code of R for this section can be downloaded here. You may see the explanation of the Script at the bottom of this section. Say, we have one set of sample consist of 10 data and we want to use mean to describe the center of the data. Type the following command in R console to generate 10 random data from normal distribution with mean 10, standard error 8: > x<-rnorm(10,10,8) Now we have generated 10 data and stored them into a variable name x. To see the content of x, just type the variable name
Variable x is a vector with 10 elements and the index of the element start with number [1]. This list is continued in the second row, start with index [7]. Suppose you have download the script I provided here and save it in directory name “D:/MyDirectory”, then you can load this script into R with the following command
Alternatively you can use menu File – Source R code... and pointing to the script file. Then you can apply the dataset x to the “boot.mean” script. Inside this script is a function [boot.mean<-function(x,n,k,alpha)] that has the following inputs:
Suppose you want to generate 10 samples, each sample has 500 replication from the orginal data set x with 10% significant level, you type > boot.mean(x,10,500,0.1) The output is as follows: Mean Original Sample : 11.03288 bootstrap standard error = 2.034639 90 % Confidence Interval for Mean Statistic:
This output show that using 500 Bootstrap replications, we found that the mean statistic for our data in vector x, which is 11.033. The bias is only about -0.027, and its standard error is about 2.034. Then the 90% confidence interval for mean statistic is (7.6, 14.24). The histogram of mean of Bootstrap samples is nearly normal because the number of Bootstrap replications is quite large. The rest of this section will discuss about how the code of boot.mean works. The code itself is described as follow
I will explain the code part by part. Part I Part II Part III Part IV Part V Part VI Part VII Part VIII
Preferable reference for this tutorial is Filiola, L., (2006) Bootstrap Computation using R, http://people.revoledu.com/kardi/tutorial/Bootstrap/Lyra/index.html |
|||||||||||||||
|
||||||||||||||||
© 2006 Kardi Teknomo. All Rights Reserved. Designed by CNV Media |
||||||||||||||||