% This is a simple LaTex sample document that gives a submission format
%   for IEEE PAMI-TC conference submissions.  Use at your own risk.

% Make two column format for LaTex 2e.\
\documentclass[12pt,twocolumn]{article} %,twocolumn
\usepackage{times,amsmath,amsfonts}

% Use following instead for LaTex 2.09 (may need some other mods as well).
%\documentstyle[times,twocolumn]{article}
\usepackage[dvips]{graphicx,graphics}
% Set dimensions of columns, gap between columns, and paragraph indent
\setlength{\textheight}{10in} \setlength{\textwidth}{7in}
%\setlength{\columnsep}{0.3125in} \setlength{\topmargin}{0in}
\setlength{\headheight}{0in} \setlength{\headsep}{-1in}
\setlength{\parindent}{1pc}
\setlength{\oddsidemargin}{-.5in}  % Centers text.
\setlength{\evensidemargin}{-.5in}

% Add the period after section numbers.  Adjust spacing.
\newcommand{\Section}[1]{\vspace{-8pt}\section{\hskip -1em.~~#1}\vspace{-3pt}}
\newcommand{\SubSection}[1]{\vspace{-3pt}\subsection{\hskip -1em.~~#1}
        \vspace{-3pt}}
\newcommand{\bqn}{\begin{eqnarray}}
\newcommand{\eqn}{\end{eqnarray}}
\newcommand {\diff}[1] {\frac{\partial}{\partial #1}}
\newcommand{\jacob}[3]{\frac{\partial^2 #3}{\partial #1 \partial #2}}
\newcommand{\der}[2]{\frac{\partial #2}{\partial #1}}
\begin{document}

% Make title bold and 14 pt font (Latex default is non-bold, 16pt)
\title{Stat 471: Lecture 15\\
Bootstrap I.}
% For single author (just remove % characters)
\author{Moo K. Chung\\
mchung@stat.wisc.edu}
% For two authors (default example)
\maketitle \thispagestyle{empty}
\begin{enumerate}
\item In previous lecture, we generated pseudo populations based
on parametric model $N(\mu,\sigma^2)$. Now we show a technique
called {\em bootstrap} where no parametric assumptions are made.
See Efron and Tibshirani (1993) An introduction to the bootstrap
for detail. Given a random sample ${\bf x}=(x_1,\cdots,x_n)$, The
CDF of true population, $F$ was estimated as the proportion of the
total sample points that is equal or less than $x$, i.e.
$$\hat F(x) = \sum_{i=1}^n \mathbb{I}_{(-\infty, x_i)}(x).$$
Note that $\hat F(x_{(i)})=i/n$ and $\hat F(x_{(i+1)})=(i+1)/n$.
So we are treating each sample point to occur with equal
probability $1/n$. Based on this idea, we resample {\em with
replacement} from ${\bf x}$ and we will denote the new sample as
${\bf x}^{*}$. If we resample $m$ times, we denote them by ${\bf
x}^{*1}, \cdots, {\bf x}^{*m}$.

\begin{verbatim}
boot=inline('x(unidrnd( length(x),
m,length(x)))','x','m');
x=[5 8 3 2];
>>bs=boot(x,3)
bs = 2     3     8     8
     3     8     3     2
     2     8     3     3
\end{verbatim}

\item Suppose ${\bf X}= (X_1,\cdots,X_n) \sim F$. Suppose we are
estimating $\theta$ by $\hat \theta({\bf X})$. The distribution of
$\hat \theta({\bf X})$ would be an interest for statistical
inference but it might be difficult to compute analytically. In
this situation, we generate $m$ bootstrap data ${\bf
X}^{*1},\cdots, {\bf X}^{*m}$ and obtain the bootstrap
replications of $\hat \theta$, $$\hat \theta^{*i} = \hat
\theta({\bf X}^{*i}).$$

These bootstrap resamples provide us with an estimate of the
distribution of $\hat \theta$. In particular, we can estimate
$\mathbb{E} \; \hat \theta({\bf X})$ and ${\bf Var} \; \hat
\theta({\bf X})$ by

$$\mathbb{E} \; \hat \theta({\bf X}) \approx \bar \theta^*=\sum_{i=1}^m \hat \theta({\bf X}^{*i})/m$$
$${\bf Var} \; \hat \theta({\bf X}) \approx \sum_{i=1}^m \Big(\hat \theta ({\bf X}^{*i}) -
\bar \theta^*\Big)^2/(m-1)$$

From $\tt{strength.data}$, let us estimate the population mean and
variance based on 200 bootstrap replications. For population mean,
we use $\hat \theta({\bf X})=\bar X$.For population variance, we
use $\hat \theta({\bf X}) = \sqrt{n}\bar X$.
\begin{verbatim}
bs=boot(arm,200); %200x147 matrix
bsmean=mean(bs,2)
>>[mean(arm) mean(bsmean)]
 ans =
   78.7517   78.9025

%MATLAB built-in function
>>mean(bootstrp(200,'mean',arm))
ans =
   78.7799
%For matrices, var(X) is a row
%vector containing the variance
%of each column.
>>[var(arm) 147*var(bsmean)]
ans =
  445.6040   423.0257
\end{verbatim}

\item Read Bootstrap bias estimation and confidence interval from
your text book p.219-227.
\end{document}

[mean(bsmean)-1.645*std(bsmean) mean(bsmean)+1.645*std(bsmean)]
