How I See Bootstrap, Tests and KDE

Yihui Xie

Stat546 Final Project

https://yihui.org

1

A nonconformist

2

Bootstrap is easy

but it took me a long while to understand it (I'm an MBA?)

3

Variablility plot?

when it is difficult to calculate the exact CI

4

Test of randomness

a tale of two coins

5

See tests

how do runs look like in our eyes?

6

Kernel density estimation

do we really need to care about the binwidth?

7

2D KDE

histograms are so mundane!

8

Same story

## adpated from demo('bivar') in rgl
rgl.demo.bivar = function(x, y, bw, ngrid = 25, ...) {
library(MASS); library(rgl)
n = length(x)
denobj = kde2d(x, y, bw, n = ngrid)
den.z = denobj$z; xgrid = denobj$x; ygrid = denobj$y
bi.z = dnorm(xgrid) %*% t(dnorm(ygrid))
zscale = 20; clear3d()
spheres3d(x, y, rep(0, n), radius = 0.1, color = "#CCCCFF")
surface3d(xgrid, ygrid, den.z * zscale, color = "#FF2222", alpha = 0.5)
surface3d(xgrid, ygrid, bi.z * zscale, color = "#CCCCFF", front = "lines")
}
set.seed(31415)
n = 50; x = rnorm(n); y = rnorm(n)
rgl.demo.bivar(x, y, 2)
## change binwidth interactively
library(gWidgetsRGtk2)
options(guiToolkit = 'RGtk2')
gslider(from = 0.1, to = 10, by = 0.1,
container = gwindow("Change binwidth"),
handler = function(h, ...) {
rgl.demo.bivar(x, y, bw = svalue(h$obj))
})
## what you should really do
res = kde2d(x, y)
contour(res$x, res$y, res$z)
points(x, y, pch = 20)
9

Vote Compass

beautiful but...

10

Conclusions

11
#

1 / 11