% 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[11pt,twocolumn]{article} %,twocolumn
%\usepackage[dvips]{graphicx,graphics}
%\usepackage{times,amsmath,amsfonts}

% Use following instead for LaTex 2.09 (may need some other mods as well).
% \documentstyle[times,twocolumn]{article}

% Set dimensions of columns, gap between columns, and paragraph indent
\setlength{\textheight}{9.9in} \setlength{\textwidth}{6.9in}
%\setlength{\columnsep}{0.3125in} \setlength{\topmargin}{0in}
\setlength{\headheight}{0in} \setlength{\headsep}{-1in}
\setlength{\parindent}{1pc}
\setlength{\oddsidemargin}{-.2in}  % Centers text.
\setlength{\evensidemargin}{-.2in}

% 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}

% Don't want date printed
%\date{January 23, 2003}

% Make title bold and 14 pt font (Latex default is non-bold, 16pt)
\title{Stat 312: Lecture 15\\
Two-sample $t$ test}

% For single author (just remove % characters)
\author{Moo K. Chung\\
mchung@stat.wisc.edu}
%\date{Feb 20, 2003}
% For two authors (default example)
\maketitle \thispagestyle{empty} \subsection*{Concepts}
\begin{enumerate}
\item Pooled sample variance:
$$S_p^2 = \frac{(n-1)S_X^2 + (m-1)S_Y^2}{n+m-2}.$$

\item Let $X_1,\cdots,X_n$ and $Y_1,\cdots,Y_m$ be two independent
samples from normal distributions with the same population
variance. The test statistic for testing
$$H_0: \mu_X = \mu_Y \mbox{ vs. } H_1: \mu_X \neq \mu_Y$$
$$T=\frac{\bar X - \bar Y -(\mu_X -\mu_Y)}{S_p\sqrt{1/n + 1/m}} \sim t_{n+m-2}.$$
Reject $H_0$ if $|T| > t_{\alpha/2,n+m-2}$.

\end{enumerate}
\subsection*{In-class problems}  {\em Example 1.} A study
was conducted to compare the weights of cats and dogs. Weights of
cats: 20, 21, 35, 13, 21, 10. Weights of dogs: 31, 10, 20, 40.
Assume that the population variance to be same for both cats and
dogs. Is there any difference between the weights of cats and
dogs?
\begin{verbatim}
> x<-c(20,21,35,13,21,10)
> y<-c(31,10,20,40)
> sqrt((5*var(x)+3*var(y))/8)
[1] 10.52824
> t=(mean(x)-mean(y))/(10.53*sqrt(1/5+1/3))
> t
[1] -0.6827026
> qt(0.05,8)
[1] -1.859548
\end{verbatim}
If you use R, it is very easy to do two sample hypothesis testing.
\begin{verbatim}
>t.test(x,y,alternative="two.sided",
var.equal=TRUE,conf.level=0.9)
        Two Sample t-test
data:x and y t = -0.7725, df = 8,
p-value = 0.462 alternative
hypothesis: true difference in means is not equal to 0 90 percent
confidence interval:
 -17.88739   7.38739

>t.test(x,y,alternative="two.sided",
conf.level=0.9)
        Welch Two Sample t-test
data:x and y t = -0.7073,df = 4.778,
p-value = 0.5124 alternative
hypothesis: true difference in means is not equal to 0 90 percent
confidence interval:
 -20.361647   9.861647
\end{verbatim}
{\em Example 2.} A cat named Tom catches average 3 mice per day
with the sample standard deviation of 1 for 10 days. A cat named
Jerry catches average 4 mice per day with the sample standard
deviation of 1.2 for 8 days. Which cat do you think mice would
hate the most at level 0.05?\\
\begin{verbatim}
> s<-sqrt((9*1^2+7*1.2^2)/(10+8-2))
> (3-4)/(s*sqrt(1/10+1/8))
[1] -1.930543
> qt(0.05,16)
[1] -1.745884
\end{verbatim}
\subsection*{Self-study problems} Compute a CI for $\mu_X - \mu_Y$
in Example 1. Please read p. 370. section Pooled $t$-Procures.
Example 9.6., 9.7. using Concept 2.
\subsection*{Homework 5.} Due April 1. 11:00am. Exercise 8.50., 8.54., 9.2., 9.4.,
 9.20., 9.22. Use Concept 2 when you do two-sided $t$ tests.\\
\end{document}
