% 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 14\\
Monte-Carlo Inference II.}
% 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 Estimating type I error. When doing inference, your decision
can be wrong in two ways. The first is a {\em type I error}, which
occurs when we reject $H_0$ when in fact it is true. $P(\mbox{
type I error })=P(\mbox{reject} H_0 | H_0 \mbox{true}) =\alpha$.
The resulting $\alpha$ is called the significance level of the
test. In the $\tt{strength.data}$ example, we reject $H_0$ if
$t<-2.37$ or $t>0.91$ at $\alpha=0.1$ level.
\begin{verbatim}
>> quantile(t,[0.1 0.9])
ans = -1.9975  0.5598
\end{verbatim}
So the $0.2$ level test would be to reject $H_0$ if $t < -2.00$ or
$t>0.56$.


\item The $P$-value is the smallest level of significance at which
$H_0$ would be rejected (You are supposed to know this fact-
STAT312). The smaller the $P$-value, it is easier to reject $H_0$.
 Since our observed
$t=-0.72$, we did not reject $H_0$. In this example, let us find
the $P$-value. We reject $H_0$ if $t < c_L$ or $t > c_R$ at
$\alpha$ level. If $c_L=-0.73$, we can not reject $H_0$. So
$c_L\geq -0.72$ and if $c_L$ becomes large, the significance level
increases. So the minimum significance level is obtained when
$c_L=-0.72$.
\begin{verbatim}
>>size(find(sort(t)<=-0.72),1)/m
ans = 0.4963
>>2*(0.5-0.0037)
ans = 0.0074
\end{verbatim}

\item Estimating Type II error. A {\em type II error} occurs when
we fail to reject $H_0$ when $H_0$ is actually false. $$P(\mbox{
type II error }) = P(\mbox{ not reject } H_0 | H_0 \mbox{
false})=\beta.$$ The statistical power of a test is defined as
$$Power = 1 - \beta.$$ It is the probability of not making a type II error and it measures
the ability of the test to detect a false null hypothesis. It can
be estimated by counting the number of times the test fail to
reject $H_0$ when $H_0$ is false.
\begin{figure}
\centering
\includegraphics[scale=0.35]{lecture14-1.eps}
\end{figure}
Let's compute the power for $\tt{strength.data}$ example with
$\alpha=0.2$.  We assume $\mu=\mu_0 \neq 80$ and use the statistic
$T=(\bar X - \mu)/(S/\sqrt{n})$. The rejection rule if $T$ is not
in $(-1.9975, 0.5598)$.
\begin{verbatim}
n=size(arm,1); m=10000;
 cL=-1.9975; cU=0.5598;
for i=70:90
  mu_a=i;
  for j=1:m
    x=sigma*snrnd(n)+mu_a;
    t(j)=(mean(x)-80)/(std(x)/sqrt(n));
  end;
  beta(i)= sum((cL<t)&(t<cU))/m;
end;
plot([70:90],1-beta(70:90))
\end{verbatim}
\item Read Chapter 6 Bootstrap. Lecture 15-20 will be on
bootstrap.
\end{document}
n=size(arm,1); m=10000;
 cL=-1.9975; cU=0.5598;

 for i=70:90
 i
  mu_a=i;
  for j=1:m
    x=sigma*normrnd(0,1,n,1)+mu_a;
    t(j)=(mean(x)-80)/(std(x)/sqrt(n));
  end;
  beta(i)= sum((cL<t)&(t<cU))/m;
end;
