% prepared for statweave
% title: lesson01-outline-swv
% expansionState: 0,1,2,3,7,12,13,14,17,21,23,24,27,28,30,32,34,35,36


\section{Introduction}
\subsection{Introduction}

\begin{frame}
\frametitle{Introduction}\stepcounter{handoutframe}\zlabel{\thisFileName:slide:\thehandoutframe}

\begin{itemize}
\item This is just a small lesson for illustration

\begin{itemize}
\item Small is important
\end{itemize}
\item Most of what we need is already here

\item We'll add some code, add a figure, and move things around 
\end{itemize}
\end{frame}


\begin{frame}[fragile,]
\frametitle{Starting Up}\stepcounter{handoutframe}\zlabel{\thisFileName:slide:\thehandoutframe}

\begin{itemize}
\item We'll use the \stliteral{auto} dataset
\begin{Statacode}{savecode,saveout,}
sysuse auto
\end{Statacode}
\recallcode{lastchunk}
\mode
<article>
\recallout{lastchunk}
\mode
<all>


\item As we all know, this is a US-centric dataset about old cars

\item We would like to make the dataset metric-friendly

\item We would like to model energy consumption of these ancient cars
\end{itemize}
\end{frame}



\section{Basics}
\subsection{Data Management and EDA}

\begin{frame}[fragile,]
\frametitle{\index{analysis|(}%
\index{metric system}Converting the Data to a Reasonable System}\stepcounter{handoutframe}\zlabel{\thisFileName:slide:\thehandoutframe}

\begin{itemize}
\item We'd like to make the dataset metric-friendly

\item We'll run the conversion code in the lesson, but show it only in the handouts
\begin{Statacode}{savecode,saveout,}
// Changing mpg to liter/100km
** 1 mile = 1.609 km; 1 gallon = 3.7854 liters
gen lp100km = 100/(mpg*(1.609 / 3.7854))
label var lp100km "Liters per 100km"

// Trunk size in liters
rename trunk trunk_cuft
** 1 inch = 2.54 cm, 1 foot = 12 inches, 1000 cc = 1 liter
gen trunk = (trunk_cuft*(12*2.54)^3)/1000
label var trunk "Trunk capacity (liters)"

// Weight in Kilos
** 1kg = 2.205 lb
rename weight weight_lb
gen weight = weight_lb / 2.205
label var weight "Weight in kg"

// Length in cm
rename length length_in
gen length_cm = length_in * 2.54
label var length_cm "Length in cm"

// Turning radius in cm
rename turn turn_circ_ft
gen turn_rad = round((turn_circ_ft * 12 * 2.54)/(2*c(pi)))
label var turn_rad "Turning radius in cm"

// Displacement in cc
rename displacement displacement_cuin
gen displacement = displacement_cuin * 2.54^3
label var displacement "Displacement in cc"
\end{Statacode}
\mode
<article>
\recallcode{lastchunk}
\recallout{lastchunk}
\mode
<all>

\end{itemize}
\end{frame}


\begin{frame}[fragile,]
\frametitle{A Peek at the Dataset}\stepcounter{handoutframe}\zlabel{\thisFileName:slide:\thehandoutframe}

\begin{itemize}
\item Here is the structure of our new dataset
\begin{Statacode}{savecode,saveout,}
describe
\end{Statacode}
\recallcode{lastchunk}
\mode
<article>
\recallout{lastchunk}
\mode
<all>


\item Here are the summary statistics
\begin{Statacode}{savecode,saveout,}
summarize
\end{Statacode}
\recallcode{lastchunk}
\mode
<article>
\recallout{lastchunk}
\mode
<all>


\item We now should look closer
\end{itemize}
\end{frame}


\begin{frame}[fragile,]
\frametitle{A Graph Matrix}\stepcounter{handoutframe}\zlabel{\thisFileName:slide:\thehandoutframe}

\begin{itemize}
\item We can look at dependencies
\begin{Statacode}{label=grmat,savecode,hide=TRUE,}
graph matrix lp100km weight displacement foreign
\end{Statacode}
\recallcode{grmat}

% found a figure which wants to be output...

\begin{Statacode}{echo=FALSE,hide=TRUE}
graph export Graphics/grmat.eps, replace
\end{Statacode}
\mode
<presentation>

\begin{center}
{\includegraphics[height=\presgphht,keepaspectratio=TRUE]{\pathprefix/Graphics/grmat}
}

\end{center}
\mode
<all>
\mode
<article>

\begin{center}
{\includegraphics[height=\handgphht,keepaspectratio=TRUE]{\pathprefix/Graphics/grmat}
}
\end{center}
\mode
<all>

\end{itemize}
\end{frame}

\subsection{Basic Analysis}

\begin{frame}[fragile,]
\frametitle{A Simple Model}\stepcounter{handoutframe}\zlabel{\thisFileName:slide:\thehandoutframe}

\begin{itemize}
\item From our graph, it appears we should try
\begin{Statacode}{savecode,saveout,}
regress lp100km weight displacement foreign
\end{Statacode}
\recallcode{lastchunk}
\mode
<article>
\recallout{lastchunk}
\mode
<all>


\item The coefficient of weight is \Stataexpr{%6.5f _b[weight]} with a $p$-value of \Stataexpr{%9.8f 2*ttail(e(df_r),abs(_b[weight])/_se[weight])}
\end{itemize}
\end{frame}


\begin{frame}
\frametitle{Some Great Explanations}\stepcounter{handoutframe}\zlabel{\thisFileName:slide:\thehandoutframe}

\begin{itemize}
\item Heavier cars use more gas

\begin{itemize}
\item After adjusting for engine size and place of manufacture
\end{itemize}
\item Non-US made cars use more gas

\begin{itemize}
\item After adjusting for weight and engine size
\end{itemize}
\item Engine size is not important

\begin{itemize}
\item After adjusting for weight and place of manufacture
\end{itemize}\end{itemize}\index{analysis|)}
\end{frame}



\section{Conclusion}
\subsection{Conclusion}

\begin{frame}
\frametitle{Conclusion}\stepcounter{handoutframe}\zlabel{\thisFileName:slide:\thehandoutframe}

\begin{itemize}
\item These results are interesting

\item We could make the results more interesting with more grant money
\end{itemize}
\end{frame}

