Diff for "FAQ/bootR/gradeg" - CBU statistics Wiki
location: Diff for "FAQ/bootR/gradeg"
Differences between revisions 3 and 4
Revision 3 as of 2008-04-10 13:52:00
Size: 862
Editor: PeterWatson
Comment:
Revision 4 as of 2013-03-08 10:17:11
Size: 864
Editor: localhost
Comment: converted to 1.6 markup
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
The above codes generates the results from the [http://imaging.mrc-cbu.cam.ac.uk/statswiki/StatsCourse2007 exploratory data analysis grad talk] and shows the undue influence of outliers in computing means from skewed data. The above codes generates the results from the [[http://imaging.mrc-cbu.cam.ac.uk/statswiki/StatsCourse2007|exploratory data analysis grad talk]] and shows the undue influence of outliers in computing means from skewed data.

R code for bootstrapped confidence intervals for means and medians from a skewed sample

The above codes generates the results from the exploratory data analysis grad talk and shows the undue influence of outliers in computing means from skewed data.

y <- c(0,0,0,4,4,5,5,5,6,6,6,6,6,6,6)

nsamp <- 1000

b <- rep(0,nsamp)
c <- rep(0,nsamp)

for (j in 1:nsamp) {
x <- 1:15

yb <- sample(x, size=15, replace=T)

y2 <- y[yb]

b[j] <- median(y2)
c[j] <- mean(y2)

}

% Estimate of the mean of the median

md <- median(b)
mn <- median(c)

% 95% CI
% make sure nsamp is a multiple of 20

bs <- sort(b)
ind <- trunc(0.05*nsamp)
bs[ind]
ind <- trunc(0.95*nsamp)
bs[ind]

cs <- sort(c)
ind <- trunc(0.05*nsamp)
cs[ind]
ind <- trunc(0.95*nsamp)
cs[ind]

None: FAQ/bootR/gradeg (last edited 2013-03-08 10:17:11 by localhost)