\chapter{Future Direct Spectroscopic Detection of Hot Jupiters with IGRINS\footnote{
    This chapter was previously published \citep{Gullikson2013}. The co-author, Mike Endl, was my co-supervisor at the time and provided much of the inspiration for the work as well as a great deal of technical assistance.
}}
\label{chap:hotjup}
Several authors have used a variant of the method we described in  Chapter \ref{chap:psi1dra} to search for emission from ``Hot Jupiter`` planets orbiting a sun-like star. In this case the flux ratio is much more extreme, but still possible with enough high signal-to-noise ratio spectra. In this chapter, we generate simulations of the IGRINS instrument to assess whether it can detect Hot Jupiter emission.  While the instrument was being built at the time of publication, it is now functioning on the 2.7m telescope at McDonald Observatory and a pilot survey based on this work is in progress.

\section{Introduction}
With about 1600 confirmed extrasolar planets \citep[from
exoplanets.org:][]{exoplanet}, the time for characterization of these
planets is here. A first step towards characterization is a determination of
the planet mass. Most of the exoplanets so far discovered around nearby stars were
found using the radial velocity technique, which measures the periodic
Doppler shift of the parent star. Unfortunately, the inclination of the orbit cannot be determined
without another complementary method. This means that planet masses from
radial-velocity surveys are only \emph{minimum} masses. In principle, precise astrometry could provide the complementary measurement that is needed to determine the true planet mass. However, the astrometric motion is very difficult to detect with current technology. The amplitude of the motion of a sun-like star with a Jupiter-mass planet orbiting at 0.1 AU and a distance from Earth of 10 pc is roughly $20 \mu$as, an order of magnitude below the precision of the Hubble Space Telescope Fine Guidance Sensors \citep{Benedict2006} and will be very near the precision of GAIA \citep{Sozzetti2001}.

We can measure the true mass and inclination of a planet only if the
radial velocity of the planet was known as well as that of its parent
star. There are two ways that the
radial velocity of an orbiting planet could be measured: light
reflected from the parent star or the characteristic spectrum of the planet itself. Both methods require high resolution spectroscopy in order to detect the doppler motion of the spectral lines. Several groups have
attempted to detect the reflected light from orbiting planets, but at
the time of this writing none have been successful \citep{Collier2002,
  Rodler2008, Rodler2010, Langford2011} and have only been able to set upper limits on the planet albedo ($A_B \sim 0.1
$).

While searches for reflected light are best done in the optical, the
thermal emission from a $\sim 1000$K planet will peak in the
near-infrared. The thermal emission from a small group of planets has been detected,
including HD209458b \citep[e.g.][]{Knutson2007, Swain2008,
  Cubillos2010}, HD189733b \citep[e.g.][]{Grillmair2007, Knutson2007_2,
  Char2008, Agol2010}, Wasp-3b \citep{Zhao2012}, and even the
Super-Earth 55 Cnc b \citep{Demory2012}. These detections were mostly made
using either Spitzer photometry or low-resolution spectroscopy, and
they are all transiting planets. Recently, the emission spectrum from Tau Boo b \citep{Brogi2012, Rodler2012}, HD 189733b \citep{deKok2013}, and possibly 51 Peg b \citep{Brogi2013} has been detected in high resolution using VLT/CRIRES. In this paper, we describe a similar technique using the IGRINS instrument, which offers a much larger spectral range in a single observation than CRIRES, and is expected to see first light on the 2.7m Harlan J. Smith Telescope at McDonald Observatory in late 2013.

There are several challenges to detecting the planet's near-infrared spectrum, especially in high resolution. The very low flux ratio between the planet and the star ($F_p/F_s \sim 10^{-4}$ in the K-band) requires a very sensitive instrument and a high signal-to-noise ratio (S/N), which is very challenging on current near-infrared spectrographs. Second, the near-infrared spectrum is highly contaminated by absorption from the Earth's atmosphere (telluric absorption). In order to detect a planetary spectrum, the telluric lines must be removed very well. Finally, the stellar spectrum must be removed to detect the planetary spectrum. This is extremely challenging for non-transiting planets, for which the planet is never blocked by the star.

In this chapter, we investigate a technique to detect the spectrum from an approximately Jupiter mass object on a very close orbit (a Hot Jupiter) using the near-infrared spectrograph IGRINS. We briefly describe the IGRINS instrument and the simulated observations in Section \ref{paper2_sec:method}. In Section \ref{paper2_sec:results}, we test the sensitivity of our detection method to the S/N of the observations, the efficiency of heat redistribution from dayside to nightside in the planet's atmosphere, and the model atmosphere dependence of the method. We summarize our results and compare our sensitivity to the recent detections of Hot Jupiters in Section \ref{paper2_sec:summary}.

\section{Instrument and Methodology}
\label{paper2_sec:method}
The IGRINS instrument is explained in detail in \cite{IGRINS}. IGRINS
is an immersion grating echelle spectrograph, and is capable of observing the entire H (1.4-1.8 $\mu m$) and K (2.0-2.4 $\mu m$) spectral windows at once,
with a resolution of $R=\lambda / \Delta \lambda \sim 40000$. IGRINS was commissioned on the 2.7-meter Harlan J Smith telescope at McDonald Observatory in the spring of 2014, about 1 year after this chapter was originally published.

We make several assumptions and simplifications in this work. We
ignore any \emph{instrumental} effects that may introduce systematic noise, although we do introduce systematic noise in the form of telluric contamination. We also ignore any light reflected from the star, since it contributes little to the total planet brightness in the H and K bands. Finally, we assume the IGRINS detector has equal sensitivity to all wavelengths of light, so the signal-to-noise ratio is set only by the light from the target.

There are three main steps in our simulated observing program: generating
a series of synthetic observations, removing the signature of Earth's
atmosphere as well as the parent star's spectrum, and searching for
the planet signal in the residuals. Each of these steps is detailed
below.

\subsection{Synthetic Observation Generation}
\label{paper2_sec:obsgen}
An observed spectrum of a star and planet system can be divided into
three parts: the star, the planet, and the Earth's atmosphere
(telluric contamination). We use two test cases for this work: HD 189733 and HD 209458. The basic parameters of the systems are given in Table \ref{paper2_tab:planet}. We choose these planets as test cases becase they are very well-studied, with detections of the atmosphere both in transmission and emission. As a result of this, they are one of the very few planets with constrained atmospheric temperature-pressure profiles and chemical abundances. These planets are also useful as test cases since HD 209458b is thought to have a thermal inversion layer in its atmosphere \citep{Knutson2008}, while HD 189733b does not \citep{Char2008}.

 We simulate the stellar and planetary spectra using a code based
on the Phoenix-ACES stellar atmosphere code \citep[described in][]{Barman2011}, modified to self-consistently treat a planet with intense incoming stellar radiation by using the stellar radiation field as a boundary condition on $F_{\nu}$.  \citep{Barman2001}. For this work, we used one dimensional spherical geometry, with no clouds and solar abundance ratios \citep{Asplund2005}. The temperature-pressure profiles are described in \cite{Barman2008} and \cite{Barman2002} for HD 189733b and HD 209458b (respectively). The chemical abundances are solved at each layer by assuming complete chemical equilibrium.

The absorption due to earth's atmosphere was modeled using the Line-By-Line Radiative Transfer Model (LBLRTM)
code \citep{Clough2005}. This code takes the pressure, temperature,
and abundance of several molecular species at a series of heights in
the atmosphere, and outputs a transmission spectrum. The code also
requires a line list containing the molecular
line strengths and positions which, along with the molecular abundance and the airmass of the observation,
determines the amount of absorption at a given wavelength. We use the HITRAN database \citep{Rothman2009} for the line
list.

The synthetic observations were made by first adding the star and
planet model spectra at the appropriate flux ratio and
Doppler shifts. The flux ratio was determined by the model
spectra themselves, multiplied by the radius of the body. We determined the Doppler shift by fixing the orbital parameters and masses of both the star and planet (which we will ultimately recover). Synthetic observations were made at
several phases in the planet's orbit as well as different phases of the \emph{Earth's} orbit around the Sun, resulting in a variety of relative radial velocities between the star, planet, and telluric spectral lines.

Hot Jupiters are expected to be tidally locked with their parent stars
\citep{Fabrycky2010}, meaning there are permanent day and night sides. The extent
of heat redistribution from the dayside to the nightside is uncertain,
but appears to vary throughout
the Hot Jupiter planetary class. \cite{Knutson2007_2} find that
HD189733 b is consistent with a high degree of heat redistribution
between its day and night side. Conversely, \cite{Harrington2006} find
that $\nu$ And b is consistent with no heat redistribution.

For planets with little heat redistribution, the planetary spectrum will change throughout the orbit, as different amounts of the cold nightside are exposed. Without a full suite of planetary atmospheres calculated with a self-consistent phase curve, we cannot treat the issue of heat redistribution in a fully realistic way. We approximate a planet with inefficient heat redistribution by scaling the dayside planet spectrum with a phase-dependent factor before adding it to the stellar spectrum. In this work, we consider only two cases: one with complete heat redistribution where the temperature of the planet is invariant to the orbital phase, and a second where the effective temperature seen on the nightside is some fraction ($f_\mathrm{ red}$) of the dayside temperature, resulting in a minimum scaling factor of $f_\mathrm{ red}^4$. WASP-12b, a very extreme case, has $f_\mathrm{ red} = 1/3$ \citep{Cowan2012};  we simulate observations with $f_\mathrm{ red} = 1/2$ as a reasonable value, and adopt a sinusoidal phase curve. For this case, the nightside planet spectrum is $2^4 = 16$ times dimmer than the dayside spectrum.

After adding the star and planet spectra as above, we multiply the sum by a model of the telluric absorption spectrum. We then convolve the spectrum with a gaussian instrumental profile and rebin the data according to the predicted resolution and spectral format of IGRINS \citep[Figures 2 and 3 of ][]{IGRINS}. Finally, we set the average signal-to-noise ratio by adding gaussian random noise to each pixel.

\subsection{Telluric and Stellar Line Removal}
\label{paper2_sec:tellcorr}
We now begin attempting to recover the planet spectrum from the synthetic observations. To remove the
telluric contamination, we use a method similar to that described by
\cite{Rodler2012}. With this method, a ``telluric standard'' star, which is usually an A- or B-star, is observed immediately after the science target at a similar airmass. The telluric contamination is modeled independently for both stars, and then the residuals of the science star fit are divided by the residuals of the standard star fit. Using a telluric model accounts for changes in airmass, water vapor column density, and the instrumental profile between the science and standard stars, but can leave systematic errors if certain lines have incorrect oscillator strengths. Dividing the residuals after the telluric model fit removes most of these systematic errors. We simulate observations of the science target
as described above, and simulate the observation of a B-type telluric standard
star with a 20000 K blackbody. The generation of this synthetic observation
was identical to that used for the science star, except we used a
telluric model with a different telescope altitude (airmass) and we did not add the planet model spectrum.

Since we are using a telluric model to make the observations, performing a model fit as described above will perfectly remove the telluric spectrum. In order to simulate systematic errors in the model fit, we
divided both the science star and the standard star by telluric models
that had $\pm 1\%$ water column density from the ``actual'' value used to make the
observation. This process left large telluric residuals on the order of $5-10\%$ of the continuum, but the residuals were
quite similar in both the science star and the standard star
observations. Thus, division of the science star residuals by the
standard star residuals adequately (but not completely) removes the telluric
contamination. Telluric residuals in the water bands at the edges of the H and K spectral windows were on the order of $1-2\%$ of the continuum. Figure \ref{paper2_fig:tellcorr} illustrates the telluric
removal process for a region with particularly severe telluric
contamination.

With the telluric contamination removed, the simulated observations
consist of just the star, the planet, and noise. To generate a stellar spectrum with minimal contamination from either telluric lines or planet lines, we simulate observations of the the star at
various phases in the planet's orbit as well as the Earth's orbit. After
correcting for the Doppler shift from both the Earth's motion and the star's
reflex motion, both of which are assumed known, we co-add the spectra from several observations. This
process will reduce the strength of the planet's spectral lines and any residual telluric
lines, as well as reduce the random noise in the spectrum by a
factor of $\sqrt{N}$, where N is the number of observations of the planet. The result is a very high S/N stellar template spectrum, which we subtract from each observation.  While the planetary lines are reduced in intensity in the stellar template,
they are still present at several radial velocities for any finite number of observations. Thus,
subtracting the stellar spectrum will also subtract some of the signal
we are interested in. For observations of the system at N distinct
phases, this stellar subtraction algorithm will subtract 1/N of the
planet signal. Thus, for non-transiting systems we expect the sensitivity to scale approximately linearly with the number of observations at distinct orbital phases. For systems with inefficient heat redistribution, where the different orbital phases contribute different amounts of planet flux, the scaling relation is more complicated and will depend on the phases observed. However, the general result that more observations increase the overall sensitivity is robust.

We note that our method of correcting for the telluric and stellar lines is quite different from that used in most previous work by \cite{Brogi2012, Brogi2013}, and \cite{deKok2013}, although the telluric correction is very similar to that described by \cite{Rodler2012}. In most previous work, the contamination was removed by placing all observations of the star in a matrix and removing features that are stationary in time. This works because the planet will be orbiting, and so its spectrum will shift several pixels throughout the course of the observation while the telluric and stellar lines will remain (approximately) constant. In contrast to this, we perform a physical fit to the telluric spectrum for each individual observation, and we account for the small stellar radial velocity when generating a stellar spectrum template. The method used here is more physical than that of previous work, but can be more expensive in both observational and computational time since it requires the observation of a standard star and the computation of a large number of telluric models over a wide wavelength range.

\subsection{Recovery of Planet Radial Velocity}
\label{paper2_sec:rv_recovery}
After removing the telluric and stellar lines, each observation has
been reduced to a very noisy planet spectrum. The low
planet to star flux ratio of $F_p/F_s \sim 10^{-4}$ means the
random noise generally has an amplitude greater than the variation in
the planet spectrum itself (i.e. the S/N $<1$). The situation is even more difficult in spectral regions with severe telluric absorption, where small errors in the telluric correction complicate the stellar spectrum removal and effectively add systematic noise. Nonetheless, we can still detect the planet
signature by cross-correlating the residuals against a planet model
spectrum. The cross-correlation will show a peak at the velocity
corresponding to the radial velocity of the planet.

Except for observations with extremely high S/N ratios, the cross-correlation function (CCF) for a single observation will show several peaks: one for the true planet signal, and several more coming from chance alignments with either random noise or telluric and stellar residuals. Here, we use a method similar to the one described by \cite{Brogi2012, Brogi2013} by using our knowledge of the planet's orbit. For planets found with the radial velocity technique, the \emph{stellar} radial velocity ($v_s$) is known for each observation (or orbital phase $\phi$), and the planet radial velocity ($v_p$) is simply

\begin{equation}
v_p (\phi) = v_s(\phi) \frac{M_s}{M_p}
\label{paper2_eqn:planetmass}
\end{equation}

To find the true mass of the planet, we test several guess values for the ratio of stellar mass to planet mass ($M_s/M_p$). For each value, we co-add all of the CCFs after correcting for the planet radial velocity and barycentric motion. When the mass-ratio guess is correct, chance alignments with residual noise will tend to cancel out while the CCF peaks coming from the true alignment of the planet model with the planetary spectrum add together. Thus, the total CCF shows a strong peak at 0 km s$^{-1}$, indicating the detection of the planetary spectrum. Figure \ref{paper2_fig:allcorr} demonstrates the advantage of adding the cross-correlation functions from all observed orbital phases; even though the planet is only weakly detected in a few of the individual observations, the total CCF has a very strong ($\sim 6 \sigma$) peak. We determine the correct mass-ratio by comparing the height of the CCF at 0 km s$^{-1}$ for all of the mass-ratio guesses; the correct mass-ratio will have the highest CCF peak.

\section{Results}
\label{paper2_sec:results}
We simulated a series of IGRINS observations of non-transiting Hot Jupiter systems by using model spectra for the well studied systems HD189733 and HD209458. For both systems, we calculate the minimum S/N ratio necessary to detect the planet. In this work we consider a planet detected if the total (summed) CCF has a peak at 0 km s$^{-1}$ with at least $4\sigma$ significance, and that the planet mass is recovered correctly and unambiguously. We consider the effect of heat redistribution by taking two extreme cases as described in Section \ref{paper2_sec:obsgen}, and we estimate the model dependence of our method by cross-correlating our synthetic observations against the wrong planet model spectrum. Our method of testing the model dependence is most likely pessimistic; in a real observing campaign and indeed in current searches \citep{Brogi2012, Brogi2013, Rodler2012, deKok2013} a library of planetary atmosphere grids with different temperature, pressure, and molecular abundance profiles would be tested. We consider it likely that one model in such a model library would be closer to the true planet spectrum than our two test cases are to each other (see Figure \ref{paper2_fig:modelcomp} for a visual comparison of the planet model spectra).

In general, the critical S/N ratio necessary to detect any non-transiting planet with our method depends on the ratio of the signal coming from the planet to that of the star. This ratio is not simply the flux ratio, since our cross-correlation technique requires several deep spectral lines in the planetary spectrum. If the planetary atmosphere is nearly isothermal as in WASP-12b \citep{Crossfield2012}, or has a thick haze layer in the near-infrared as HD 187333b may \citep{Gibson2012}, then the spectrum will be relatively featureless and it will be very difficult to detect in high resolution.  The critical S/N ratio can be calculated from the continuum surface flux of the planet and star ($F_\mathrm{ p, cont}$ and $F_\mathrm{ s, cont}$, respectively), the ratio of the flux in an average spectral line to the flux in the continuum for the planet ($r$), the radii of the planet and the star ($R_p$ and $R_s$, respectively), and unknown constants $A$ and $S_0$:

\begin{equation}
S/N_\mathrm{ crit} = A \frac {F_\mathrm{ s, cont}}{F_\mathrm{ p, cont}(1 - r)} \left ( \frac{R_s}{R_p} \right )^2 + S_0
\label{paper2_eqn:snrcrit}
\end{equation}

To first order, the continuum fluxes can be calculated from the blackbody fluxes and the effective temperatures of the planet and star. The planet temperature can be approximated from the stellar temperature, the semimajor axis of the planet's orbit ($a$), and the bond albedo of the planet ($A_B$) by radiative equilibrium with

\begin{equation}
T_p^4 = \frac{1-A_B}{4} \left ( \frac{R_s}{a} \right )^2 T_s^4
\end{equation}

To test the dependence on S/N, we generated a series of synthetic observations at 25 approximately evenly spaced orbital phases for average S/N ratios ranging from 100  - 1500, with both efficient and inefficient heat redistribution (see the discussion of heat redistribution in section \ref{paper2_sec:obsgen}). We did not attempt to optimize the observing schedule for the planets with inefficient heat redistribution, and so the minimum S/N ratios we find for that case may be somewhat pessimistic. We determined the minimum S/N ratio necessary to detect the planet, and report the results in Table \ref{paper2_tab:snrcrit}. In general, HD 209458b requires higher S/N to detect than HD 189733b. HD 209458 is a hotter star while the planets are roughly the same temperature, and so the flux ratio is more extreme. In addition, HD 189733b has much deeper lines throughout its spectrum, largely from a higher water abundance \citep{Madhusudhan2009}, making the detection easier. A second trend evident in Table \ref{paper2_tab:snrcrit} is that planets with inefficient heat redistribution require a larger increase in S/N ratio to detect if the wrong planet model is used, and so are more model dependent than those with efficient heat redistribution.

We now determine $A$ and $S_0$ from Equation \ref{paper2_eqn:snrcrit} from the known flux ratios and line strengths in HD 189733b and HD 209458b, along with the minimum S/N ratio values in Table \ref{paper2_tab:snrcrit}. For efficient heat redistribution, $A=0.1$ and $S_0 = 46$. Likewise, $A=0.1$ and $S_0 = 107$ for inefficient heat redistribution. With these values, we can estimate the S/N ratio necessary to detect other Hot Jupiters. The planet radius is not known for non-transiting planets, but we approximate this from mass-radius relationships for hydrogen-dominated planets given in \cite{Swift2012}. Lacking any information on the line strength for non-transiting planets, we take a typical value to be the average of our two test cases: $r = 0.83$. We use $A=0.1$ and $S_0=75$ in Equation \ref{paper2_eqn:snrcrit} to consider some level of heat redistribution. Table \ref{paper2_tab:targetlist} estimates the flux ratio for each of the non-transiting Hot Jupiter planets in the exoplanets.org database \citep{exoplanet}, assuming $A_B = 0.2$. The minimum S/N ratios were found with Equation \ref{paper2_eqn:snrcrit}. We calculate the exposure time for each target from the net atmospheric transmission in the K band, the expected $7\%$ net throughput of IGRINS (Dan Jaffe, priv. comm.), and simple Poisson statistics since these observations will be well within the source noise limit.

To estimate the uncertainty in the planet to star mass-ratio, and therefore the uncertainty in the true planet mass, we compare the significance of the $v=0$ km s$^{-1}$ point of the total CCFs for various mass-ratio guesses. As the guess begins getting closer to correct, the correct peaks in the individual CCFs will begin to align and the significance of the total peak will increase (See Figure \ref{paper2_fig:massratio}). We can estimate the mass-ratio uncertainty from the points where the significance of the total CCF peak drops $\sim 1 \sigma$ from the most significant mass-ratio. Smaller mass-ratio systems will have faster moving planets, so the individual CCF peaks only line up for a more narrow range of mass-ratio guesses than they would for more massive planets. Therefore, the the planet mass uncertainty with this method \emph{decreases} as the mass-ratio decreases, as long as the planet remains detectable. The width of the peak in Figure \ref{paper2_fig:massratio}, which is for a detection of HD 189733b, is $\sigma_{M_p/M_s} = 1.6\e{-4}$. Combining this with the stellar mass uncertainty gives a planet mass uncertainty of $\sigma_{M_p} = 0.15 M_\mathrm{ Jup}$. The width of the corresponding peak for a detection of HD 209458b is $\sigma_{M_p/M_s} = 2\e{-5}$ giving $\sigma_{M_p} = 0.03 M_\mathrm{ Jup}$. The planet mass uncertainty could be improved by focusing on phases near quadrature, rather than evenly sampling the orbit as we do in this chapter.

\section{Summary and Conclusions}
\label{paper2_sec:summary}
We have described a technique for directly detecting the near-infrared spectrum from a
non-transiting Hot Jupiter using high resolution, high signal-to-noise ratio spectra. We have applied this technique to simulated observations with the IGRINS near-infrared instrument, which is sensitive to the entire H and K bands and will begin operating on the 2.7m Harlan J. Smith Telescope at McDonald Observatory in late 2013. Using models of the well-studied Hot Jupiters HD189733b and HD209458b, we make synthetic observations at various phases of the planet's orbit and at several different barycentric radial velocities to simulate observations taken at different times of the (Earth's) year. We then remove the telluric absorption and parent star spectra, and search for the planet spectra by cross-correlating the residuals against models of the planet spectrum.

We have shown that the true mass and inclination of a Hot Jupiter planet can be recovered, and have determined the effect of S/N ratio as well as heat redistribution, and have estimated the model dependence of our method. Table \ref{paper2_tab:snrcrit} summarizes the results for our two test case planets, and Table \ref{paper2_tab:targetlist} estimates the S/N ratios and exposure times necessary to detect several known, non-transiting Hot Jupiters.

Our simulated observations are similar to the recent detections of Tau Boo b \citep{Rodler2012, Brogi2012}, HD 189733 b \citep{deKok2013}, and 51 Peg b \citep{Brogi2013}, all of which used the CRIRES high resolution spectrograph. The IGRINS instrument covers the entire H and K bands at once, rather than the $\sim 40$ nm range observed by CRIRES. Since the cross-correlation signal roughly scales as the square root of the number of deep spectral lines, we expect IGRINS to be more sensitive to detecting planets than CRIRES despite being on a smaller telescope. As well as simulating a different instrument, we simulate a different observing strategy; whereas previous work has used several hundred observations of a star over the course of a few closely-spaced nights, we have simulated an observing strategy where the star is observed $\sim 25$ times at various points in its phase \emph{as well as various times of the year}. This strategy is more compatible with a campaign to monitor several Hot Jupiters rather than using one observing run for each planet. It also allows for the easy addition of more data when it is received.

This research has made use of the Exoplanet Orbit Database and the Exoplanet Data Explorer at exoplanets.org. We would like to thank the anonymous referee for several very helpful comments, Travis Barman for generating the high-resolution model spectra for the stars and planets used in this work, and Dan Jaffe for his help with estimating the performance of the IGRINS instrument.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%                Tables                           %%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\clearpage
\afterpage{%
\begin{table}
  \centering
    \caption{Physical properties of the HD 189733 and HD 209458 planetary systems. The effective temperatures, masses, and radii are from \cite{Torres2008}, and r (the ratio of the flux in an average spectral line to the flux in the continuum for the planet) are from the model spectra used in this work (See Figure \ref{paper2_fig:modelcomp} and the discussion before Equation \ref{paper2_eqn:snrcrit}).}
  \begin{tabular}{|c|ccccc|}
    \hline
    Star & $T_\mathrm{ eff, star}$ (K) & $T_\mathrm{ eff, planet}$ (K) & M$_\mathrm{ p}$ (M$_\mathrm{ Jup}$) & R$_\mathrm{ p}$ (R$_\mathrm{ Jup}$)  & $r$ \\ \hline
    HD 189733 & 5040 & 1200 & 1.14 & 1.138 & 0.77 \\
    HD 209458 & 6065 & 1450 & 0.69 & 1.359 & 0.90 \\ \hline
  \end{tabular}

  \label{paper2_tab:planet}
\end{table}
}

\clearpage
\begin{table}
  \centering
  \caption{Summary of minimum S/N ratios needed to detect planets for our test cases. Efficient heat redistribution refers to observations where the dayside and nightside temperatures are the same, while inefficient heat redistribution is when the nightside temperature is half that of the dayside temperature. The model dependence is estimated by using different planet models to cross-correlate against the same observation (see section \ref{paper2_sec:results}). We do not attempt to simulate observations with S/N $>1500$ because such a high value would be very difficult to achieve in the near-infrared.}
  \begin{tabular}{|c|ccc|}
    \hline
    Star & Planet Model for CCF & Heat Redistribution & Critical S/N Ratio \\ \hline
    HD 189733 & HD 189733b & efficient & 200 \\
    HD 189733 & HD 189733b & inefficient & 450 \\
    HD 189733 & HD 209458b & efficient & 300 \\
    HD 189733 & HD 209458b & inefficient & 800 \\
    HD 209458 & HD 209458b & efficient & 900 \\
    HD 209458 & HD 209458b & inefficient & 1200 \\
    HD 209458 & HD 189733b & efficient & 1200 \\
    HD 209458 & HD 189733b & inefficient & $>$1500 \\ \hline
  \end{tabular}
  \label{paper2_tab:snrcrit}
\end{table}

\clearpage
\newpage
\begin{center}
\begin{longtable}{|ccccc|}

\caption{Estimated exposure times required for correctly retrieving the true masses of Hot Jupiters. The times are for a single observation; roughly 20-25 observations of the system at different phases are necessary to detect the planet. See Section \ref{paper2_sec:results} for the calculation of the flux ratio and critical S/N. \label{paper2_tab:targetlist}} \\
\hline
Star Name & $ \mathrm{K_s}$ Magnitude & K-band flux ratio & S/N required & Time Required (Minutes) \\ \hline
\endfirsthead

\multicolumn{3}{c}{{\tablename} \thetable{} -- Continued} \\
\hline
Star Name & $ \mathrm{K_s}$ Magnitude & K-band flux ratio & S/N required & Time Required \\ \hline
\endhead

\hline
\endfoot

\hline
\endlastfoot

$\tau$ Boo  & 3.36 & 1.26\e{-03} & 541 & 1.0 \\
HD 189733  & 5.54 & 3.08\e{-03} & 200 & 1.0 \\
$\upsilon$ And  & 2.86 & 8.22\e{-04} & 791 & 1.4 \\
HD 41004 B  & 6.43 & 8.95\e{-03} & 141 & 1.7 \\
HD 179949  & 4.93 & 1.22\e{-03} & 559 & 4.7\\
HD 162020  & 6.54 & 2.99\e{-03} & 272 & 4.8 \\
HD 217107  & 4.53 & 7.22\e{-04} & 890 & 8.2 \\
HD 73256  & 6.26 & 1.53\e{-03} & 461 & 10.8 \\
HD 187123  & 6.34 & 1.28\e{-03} & 534 & 15.5 \\
HD 86081  & 7.3 & 1.64\e{-03} & 434 & 25.0 \\
HD 68988  & 6.74 & 1.17\e{-03} & 576 & 26.3 \\
HIP 14810 & 6.83 & 1.05\e{-03} & 637 & 34.8 \\
HD 330075  & 7.17 & 1.23\e{-03} & 553 & 35.9 \\
HD 149143  & 6.43 & 7.71\e{-04} & 838 & 41.9 \\
HD 209458  & 6.31 & 1.21\e{-03} & 900 & 43.0 \\
HD 185269  & 5.26 & 3.05\e{-04} & 2002 & 81.0 \\
HD 118203  & 6.54 & 4.77\e{-04} & 1309 & 112.9 \\
HD 102956  & 5.66 & 2.06\e{-04} & 2935 & 253.0

\end{longtable}
\end{center}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%                Figures                          %%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{figure}[t]
  \centering
  \includegraphics[width=6.5in]{Figures/paper2_fig1.pdf}
  \caption{Telluric Correction process. \emph{Top Panel}: Original
    science star spectrum for a segment in the water band on the blue side of the K band.  \emph{Middle Panel}: Telluric residuals
    after the model fit. The science star residuals are in the upper (solid) line, and
    the standard star residuals are in the lower (dashed) line. The systematic errors we introduced appear like emission lines in both spectra. \emph{Bottom Panel}:
    Result after division of the science star residuals by the
    standard star residuals. The telluric contamination has largely been removed.}
  \label{paper2_fig:tellcorr}
\end{figure}

\begin{figure}[t]
  \centering
  \includegraphics[width=6.5in]{Figures/paper2_fig2.pdf}
  \caption{\emph{Top Panel}: Individual cross-correlation functions for simulations of HD 189733 with an average S/N = 500, and with complete heat redistribution. The velocities are shifted at each orbital phase such that the cross-correlation function should have a peak at 0 km s$^{-1}$; the planet is only detected in a few of the observations. \emph{Bottom panel}: The total cross-correlation function, after adding the cross-correlation functions for each individual observation. Here the planet is very clearly detected with $6.29 \sigma$ significance.}
  \label{paper2_fig:allcorr}
\end{figure}

\begin{figure}[t]
  \centering
  \includegraphics[width=5.5in]{Figures/paper2_fig3.pdf}
  \caption{A comparison of the HD189733 planet model with the HD209458
  planet model. The gap in the middle is is in between the H and K
  spectral windows, where water absorption in the Earth's atmosphere
  blocks most of the incoming light. HD209458b has a thermal inversion
  in its atmosphere, which generates the emission lines near 1950
  nm. HD189733 b is somewhat cooler and has more water, giving its
  spectrum stronger spectral lines.}
  \label{paper2_fig:modelcomp}
\end{figure}

\begin{figure}[t]
  \centering
  \includegraphics[width=6.5in]{Figures/paper2_fig4.pdf}
  \caption{A summary of the significance of the point at 0 km s$^{-1}$ in the total cross-correlation functions for each of the mass-ratio guesses, for a series of observations of HD 189733 with an average S/N = 500 and complete heat redistribution (the same as in Figure \ref{paper2_fig:allcorr}). The peak in this figure determines the planet to star mass-ratio, and therefore the true planet mass. The width of the peak $1 \sigma$ below its maximum determines the uncertainty in the planet mass.}
  \label{paper2_fig:massratio}
\end{figure}


\chapter{Figures, Tables, Equations, Algorithms, etc}\label{chap:design}

%Your design chapter.  I probably should include some examples on inserting figures, tables, mathematical equations, etc.

(This is supposed to be the design or methodology chapter.  Instead, we include examples on inserting figures, tables, mathematical equations\ldots i.e.\ things that you might want to include in your thesis.)

\section{Inserting Figures}\label{sec:figure}

You can draw diagrams with special \LaTeX\ commands, but this may take some extra time to learn.  I've had some forays into the \texttt{pgf} and \texttt{tikz} packages and must say I quite like the results; but as I said, they take time to learn. If you want a faster solution, you can draw your diagrams using other applications, and saving them as graphic files (EPS, PNG, JPG, PDF).

\LaTeX{} requires EPS (encapsulated postscript) graphic files when generating DVI output, and PNG, JPG or PDF when generating PDF output.

For exporting to EPS, try \url{http://www.cloudconvert.com}. It's like a Swiss knife for converting from almost any format, to almost any format.

Do note that IPS \textbf{discourages} the use of colours in your thesis, including diagrams and figures.  Phographs and colour plates are exceptions to this rule: see Section~\ref{sec:plate}.

Here's how to insert a picture with the filename \verb|pythag.eps| or \verb|pythag.png|.  I'm going to display it here with 5cm width, and the caption ``Pythagoras' Theorem''.

\begin{figure}[hbt!]
\begin{lstlisting}
\begin{figure}[hbt!]\centering
\includegraphics[width=50mm]{pythag}
\caption{Pythagoras' Theorem}\label{fig:pythagoras}
\end{figure}
\end{lstlisting}
\caption{Including a Graphics File}\label{fig:lst:graphics}
\end{figure}

The result would be:

\begin{figure}[hbt!]\centering
\includegraphics[width=50mm]{pythag}
\caption{Pythagoras' Theroem} \label{fig:pythagoras}
\end{figure}

Don't specify the extension of the graphic file.  The template will automatically look for the EPS or the PNG (or otherwise) versions, depending on whether \verb|latex| or \verb|pdflatex| was used.  The \texttt{figure} environment will also ensure that that an entry is inserted into the \emph{List of Figures} automatically -- including the figure numbering, caption and page number.

In addition, the width of the included graphics can also be specified as a percentage of the text width, e.g.~ \verb|width=.2\textwidth| would cause the graphics to occupy 20\% of the text width.

Notice that I inserted a \verb|\label| just after the \verb|\caption|.  This can be used for referencing the figure number, like this: \\
\verb|Figure \ref{fig:pythagoras}| $\to$ Figure \ref{fig:pythagoras}

This works the same for chapters, sections, tables, equations too.  In \verb|chap-intro.tex|, I labelled the Introduction chapter with \verb|\label{chap:intro}|.  I also labelled the section on inserting figures, \verb|\label{sec:figure}|.  So now I can do \\
\verb|Chapter \ref{chap:intro}| $\to$  Chapter \ref{chap:intro} \\
\verb|section \ref{sec:figure}| $\to$  section \ref{sec:figure}

Everytime the numbering of the heading changes, the reference will change automatically as well.  \textbf{This is another advantage of using \LaTeX{}}: you do not need to manually update the reference counters (nor the Table of Contents, List of Figures and Tables) whenever you add or remove figures, tables, sections or chapters.

You might also want to try out \texttt{JpgfDraw}: it is a vector graphics and drawing application (requiring Java), and can export to \LaTeX{} code which you can paste into your \LaTeX{} source. \texttt{JpgfDraw} is available from \url{http://theoval.cmp.uea.ac.uk/~nlct/jpgfdraw/index.html}.

\section{How Do I Do Subfigures?}
Here's an example on how to do subfigures (and similarly subtables):

\begin{figure}[hbt!]
\begin{lstlisting}
\begin{figure}[hbt!]
  \begin{minipage}{.49\textwidth}
  \centering
  \subfloat[First caption]{\includegraphics[width=3cm]{pythag}} \label{fig:sub1}
  \end{minipage}
  \hfill
  \begin{minipage}{.49\textwidth}
  \subfloat[Second caption]{\includegraphics[width=0.8\textwidth]{USMScience}}\label{fig:sub2}
  \end{minipage}

  \caption{This is the main caption of the figure.}
  \label{fig:main}
\end{figure}
\end{lstlisting}
\caption{Creating subfigures within figures}
\end{figure}

\begin{figure}[hbt!]
  \begin{minipage}{.49\textwidth}
  \centering
  \subfloat[First caption]{\includegraphics[width=3cm]{pythag}} \label{fig:sub1}
  \end{minipage}
  \hfill
  \begin{minipage}{.49\textwidth}
  \subfloat[Second caption]{\includegraphics[width=0.8\textwidth]{USMScience}}\label{fig:sub2}
  \end{minipage}

  \caption{This is the main caption of the figure.}
  \label{fig:main}
\end{figure}

\section{Inserting Plates}\label{sec:plate}

Colour photographs are now regarded as \emph{plates}. They must be listed in the \emph{List of Plates} instead of the List of Figures, and should be printed in colour on glossy photo paper \citep{ips:thesis:guideline:2007}.

The \texttt{usmthesis} document class defines a new \texttt{plate} environment, as well as a corresponding \verb|\listofplates| command.  (The \verb|\listofplates| command is already placed in the sample template file \verb|usmthesis.tex|.)  In short, all you need to do to insert a photograph or plate (as a graphics file \verb|USMScience.{eps,png,jpg}|) is shown in Figure~\ref{fig:lst:plate}, and you will then get Plate~\ref{plate:ppsk:usm} as the result.

\begin{figure}[hbt!]
\begin{lstlisting}
\begin{plate}[hbt!]\centering
\includegraphics[width=.9\textwidth]{USMScience}
\caption{School of Computer Sciences, USM}\label{plate:ppsk:usm}
\end{plate}
\end{lstlisting}
\caption{Inserting a Plate}\label{fig:lst:plate}
\end{figure}

\begin{plate}[hbt!]\centering
\includegraphics[width=.9\textwidth]{USMScience}
\caption{School of Computer Sciences, USM}\label{plate:ppsk:usm}
\end{plate}

\section{Inserting Tables}

Typesetting tables can be a little troublesome especially with complex layouts.  Look up \citep{roberts} to learn about some tips, or you can use the \textrm{LaTable} program (\url{http://www.g32.org/latable/}) to help you.

If using \textrm{LaTable}, when you're done designing the table, copy the whole table as \LaTeX\ code, and paste it in your source file.  (You may add additional formatting commands, like bold, italics, etc.)  If this is going to be a numbered table, remember to surround it with \verb|\begin{table}| and \verb|\end{table}|, and give it a caption, like this:

\begin{figure}[hbt!]
\begin{lstlisting}
\begin{table}[hbt!]\centering
\begin{tabular}{| l | c || r |}
\hline
\textbf{Name} & \textbf{Category} & \textbf{Quantity} \\
\hline\hline
Apple & Fruit & 10 \\
\hline
Cucumber & Vegetable & 25 \\
\hline
Daisy & Flower & 5 \\
\hline
\end{tabular}
\caption{Sample Table Only} \label{table:sample}
\end{table}
\end{lstlisting}
\caption{Typesetting Tables}\label{fig:lst:table}
\end{figure}

\begin{table}[hbt!]\centering
\begin{tabular}{| l | c || r |}
\hline
\textbf{Name} & \textbf{Category} & \textbf{Quantity} \\
\hline\hline
Apple & Fruit & 10 \\
\hline
Cucumber & Vegetable & 25 \\
\hline
Daisy & Flower & 5 \\
\hline
\end{tabular}
\caption{Sample Table Only} \label{table:sample}
\end{table}

Note also that \verb|usmthesis| is configured such that captions for figures are placed \emph{below} the figures, and captions for tables are placed \emph{above} them, in accordance with the formatting guidelines.

Many of us would have had massive headaches about lining up decimal places in table columns (as mentioned in the IPS guidelines) if not for this tip from \citep[pp.~274--276]{latex:companion}. This method uses the \verb|dcolumn| package (already loaded by \verb|usmthesis.cls|). Instead of using \verb|l,c| or \verb|r| as the column type in the \verb|tabular| declaration, use\\ \texttt{D\{\textit{input sep}\}\{\textit{output sep}\}\{\textit{decimal places}\}}.

\begin{figure}[htb!]
\begin{lstlisting}
\begin{table}[htb!]\centering
\begin{tabular}{| c | D{.}{.}{2} |}
\hline
Item & \multicolumn{1}{c|}{Reading}\\\hline
A & 1.11\\\hline
B & 3.99\\\hline
C & 2.27\\\hline
\end{tabular}
\caption{A table with decimal data}
\end{table}
\end{lstlisting}
\caption{Aligning decimal data in tables}\label{fig:align:decimal}
\end{figure}

The \LaTeX\ code in Figure~\ref{fig:align:decimal} will give you Table~\ref{tab:align:decimal}.

\begin{table}[htb!]\centering
\begin{tabular}{| c | D{.}{.}{3} |}
\hline
Item & \multicolumn{1}{c|}{Reading}\\\hline
A & 1.11\\\hline
B & 3.999\\\hline
C & 22.2\\\hline
\end{tabular}
\caption{A table with decimal data}\label{tab:align:decimal}
\end{table}

Without using \verb|dcolumn|, you'd get something like this:

\begin{table}[htb!]\centering
\begin{tabular}{| c | r |}
\hline
Item & \multicolumn{1}{c|}{Reading}\\\hline
A & 1.11\\\hline
B & 3.999\\\hline
C & 22.2\\\hline
\end{tabular}
\caption{A table with decimal data (mis-aligned)}
\end{table}

\section{Full-paged, Sideways Figures and Tables}

To make a figure appear on a landscape, full-page layout, put your \verb|\includegraphics| command in a \verb|sidewaysfigure| environment (Figure~\ref{fig:lst:sidewayfigure}).

\begin{figure}[htb!]
\begin{lstlisting}
\begin{sidewaysfigure}\centering
\includegraphics[width=\textheight]{latex-win-comp}
\caption{A full-page, sideways figure}\label{fig:sidewaysfig}
\end{sidewaysfigure}
\end{lstlisting}
\caption{Including a sideway, full-page graphic}\label{fig:lst:sidewayfigure}
\end{figure}

\begin{sidewaysfigure}
\centering\includegraphics[width=\textheight]{latex-win-comp}
\caption{A full-page, sideways figure}\label{fig:sidewaysfig}
\end{sidewaysfigure}

The resultant figure (Figure~\ref{fig:sidewaysfig}) should appear on the next page.

For a sideways table, use the \verb|sidewaystable| environment instead around your usual \verb|tabular| material.

\section{Mathematical Equations}

%Oooh I love this one.  After all, maths is the reason why Donald Knuth created \TeX{}!  It would be quite impossible for me to list all the commands, so I'll just give some example here, and you're better off looking at the various online tutorials like \cite{roberts}.  And TeXnicCenter certainly makes things much easier.

Typesetting mathematical material is one of, if not \emph{the}, strongest capabilities of \LaTeX.  After all, that was the Knuth's main motivation for creating \TeX{}.  As it is impossible to enumerate all possible mathematically-related commands and macros here, we will just give some examples.  The reader is directed to the many well-written online tutorials, such as \citep{roberts}, for more elaborate examples.  TeXnicCenter also provides many shortcut buttons for inserting mathematical symbols.

\begin{figure}[htb!]
\begin{lstlisting}
\begin{equation}\label{eq:pythagoras}
z^2 = x^2 + y^2
\end{equation}

\begin{equation}\label{eq:golden:ratio}
\phi = \frac{1}{2} (1 + \sqrt{5})
\end{equation}

\begin{equation}\label{eq:golden:ratio}
\phi = \frac{1}{2} (1 + \sqrt{5})
\end{equation}
\begin{equation}\label{eq:golden:ratio:fibonacci}
\phi = 1 + \sum ^ {\infty} _ {n=1}
                \frac{ (-1) ^ {n+1} }{ F_n F_{n+1} }
\end{equation}

Equation~\ref{eq:pythagoras} is the Pythagoras Theorem.
\eqref{eq:golden:ratio} gives the golden ratio $\phi$, and
\eqref{eq:golden:ratio:fibonacci} relates it to the Fibonacci
series.
\end{lstlisting}
\caption{Typesetting Mathematical Equations}\label{fig:lst:equation}
\end{figure}

\begin{equation}\label{eq:pythagoras}
z^2 = x^2 + y^2
\end{equation}
\begin{equation}\label{eq:golden:ratio}
\phi = \frac{1}{2} (1 + \sqrt{5})
\end{equation}
\begin{equation}\label{eq:golden:ratio:fibonacci}
\phi = 1 + \sum ^ {\infty} _ {n=1}
                \frac{ (-1) ^ {n+1} }{ F_n F_{n+1} }
\end{equation}

Equation~\ref{eq:pythagoras} is the Pythagoras Theorem. \eqref{eq:golden:ratio} gives the golden ratio $\phi$, and \eqref{eq:golden:ratio:fibonacci} relates it to the Fibonacci series.

The \LaTeX\ code to generate the above mathematics materials are shown in Figure~\ref{fig:lst:equation}.  As you can see, references to equations can be achieved with either \verb|\ref| or \verb|\eqref|.

A disclaimer: if you think the mathematic equations don't look as great as all those \LaTeX\ advocates make them out to be, that's because IPS requires Times to be used and the current offerings of free \LaTeX\ math fonts for Times don't look great. It would've been a different picture if we used Computer Modern.

\section{Acronyms}
\acresetall
If you have a list of acronyms or symbols, edit the file \verb|loa.tex| as in Figure~\ref{fig:acronym}.

\begin{figure}[hbt!]
\begin{lstlisting}
\begin{acronym}[UTMK] %% replace 'UTMK' with the longest acronym in your list
\acro{IPS}{Institut Pengajian Siswazah}
\acro{PPSK}{Pusat Pengajian Sains Komputer}
\acro{USM}{Universiti Sains Malaysia}
\acro{UTMK}{Unit Terjemahan Melalui Komputer}
\end{acronym}
\end{lstlisting}
\caption{The template \texttt{loa.tex} for acronyms}\label{fig:acronym}
\end{figure}

You can also use this acronym list to help expand it the first time you mention it in your text.  For example, the first time you use \verb|\ac{USM}|, `\ac{USM}' will be the output (without the quotes).  After that, all calls to \verb|\ac{USM}| will give `\ac{USM}' (without the quotes).  For more information, see the documentation for the \texttt{acronym} package.

% Please feel free to use whatever package you like for typesetting algorithms!
\section{Typesetting Algorithms}

As computer scientists, it is quite common to include algorithms and/or pseudocode. There are a number of different packages available, but unfortunately they tend not to work well together! I'm using \texttt{algorithmicx} here.

\begin{figure}[hbt!]
\begin{lstlisting}
\begin{algorithm}[hbt!]
\begin{algorithmic}
\Require $n \geq 0$
\Ensure $y = x^n$
\State $y \Leftarrow 1$
\State $X \Leftarrow x$
\State $N \Leftarrow n$
\While{$N \neq 0$}
\If{$N$ is even}
  \State $X \Leftarrow X \times X$
  \State $N \Leftarrow \frac{N}{2} $  \Comment{This is a comment}
\ElsIf{$N$ is odd}
  \State $y \Leftarrow y \times X$
  \State $N \Leftarrow N - 1$
\EndIf
\EndWhile
\end{algorithmic}
\caption{Computing $x^n, n > 0$}
\end{algorithm}
\end{lstlisting}
\caption{Typesetting Algorithms}\label{fig:lst:algo}
\end{figure}

\begin{algorithm}[hbt!]
\begin{algorithmic}
\Require $n \geq 0$
\Ensure $y = x^n$
\State $y \Leftarrow 1$
\State $X \Leftarrow x$
\State $N \Leftarrow n$
\While{$N \neq 0$}
\If{$N$ is even}
  \State $X \Leftarrow X \times X$
  \State $N \Leftarrow \frac{N}{2} $  \Comment{This is a comment}
\ElsIf{$N$ is odd}
  \State $y \Leftarrow y \times X$
  \State $N \Leftarrow N - 1$
\EndIf
\EndWhile
\end{algorithmic}
\caption{Computing $x^n, n > 0$}
\end{algorithm}

\section{Program Listings}

You may have noticed that I used the \verb|lstlisting| environment to typeset some of the \LaTeX{} examples -- with pretty-printing\footnote{Whether you agree that it \emph{is} pretty is another story altogether.}, too, including automatic line-breaking.  For more information, see the documentation for the \verb|listings| package: it's available online at \url{http://www.texdoc.net/pkg/listings}.

Just to give some simple example here.  For example, to typeset a ``Hello World'' Java program with syntax highlighting, you can use the following code:

\begin{figure}[hbt!]
\begin{lstlisting}[escapechar=:,language={}]
\lstset{basicstyle=\small\ttfamily, language=Java, breaklines=true, columns=fullflexible, tabsize=2}
\begin{lstlisting}
public class HelloWorld {
	public static void main( String arg[] ) {
        for (int i = 0; i < 10; i++) {
			System.out.println( "Hello World!" + i);
		}
	}
}
\end:\{:lstlisting:\}:
\end{lstlisting}
\caption{Typesetting a Java program listing}\label{fig:lst:syntax}
\end{figure}

\lstset{keywordstyle={\bfseries}}
\begin{figure}[hbt!]
\lstset{basicstyle=\small\ttfamily, language=Java, breaklines=true, columns=fullflexible, framesep=10pt, xleftmargin=16pt, tabsize=2}
\begin{lstlisting}
public class HelloWorld {
	public static void main( String arg[] ) {
        for (int i = 0; i < 10; i++) {
			System.out.println( "Hello World!" + i);
		}
	}
}
\end{lstlisting}
\caption{A pretty-printed Java program listing with syntax highlighting}
\end{figure}

If you want to turn off the syntax highlighting, set \verb|language={}|.  (See the \verb|listings| documentation for a list of programming languages for which syntax highlighting is supported.)  You can also change the \verb|basicstyle| value to get different effects: e.g. a different font family, size or text formatting.

Here's another example for a C program:

\begin{figure}[hbt!]
\begin{lstlisting}[escapechar={:}, texcl=false,language={}]
\lstset{basicstyle=\sffamily, language=C, breaklines=true, columns=fullflexible, tabsize=2}
\begin{lstlisting}
int main() {
	int c = 0;
	c = c + 1;
	printf( "%d", c );
	return 0;
}
\end:\{:lstlisting:\}:
\end{lstlisting}
\caption{Typesetting a C program listing}\label{fig:lst:c}
\end{figure}

\begin{figure}[hbt!]
\lstset{basicstyle=\sffamily, language=C, breaklines=true, columns=fullflexible, framesep=10pt, xleftmargin=.4\textwidth, tabsize=4}
\begin{lstlisting}
int main() {
	int c = 0;
	c = c + 1;
	printf( "%d", c );
	return 0;
}
\end{lstlisting}
\caption{A pretty-printed C program listing with syntax highlighting}
\end{figure}

And here is the same C program listing \emph{without} syntax highlighting (by setting \verb|language={}|):

\begin{figure}[hbt!]

\lstset{basicstyle=\sffamily, language={}, breaklines=true, columns=fullflexible, framesep=10pt, xleftmargin=.4\textwidth, tabsize=4}
\begin{lstlisting}
int main() {
	int c = 0;
	c = c + 1;
	printf( "%d", c );
	return 0;
}
\end{lstlisting}
\caption{A C program listing without syntax highlighting}
\end{figure}


\documentclass[12pt]{article}

\include{preamble}

\title{STAT 422/722 Spring 2017 PROJECT}

\author{Professor Adam Kapelner}

\date{Due February 23, 5PM at JMHH 4th floor (in the dropoff box)\\ \vspace{0.5cm} \footnotesize (this document last updated \today ~at \currenttime)}

\begin{document}
\maketitle

\section{Introduction}

In short, you will be predicting apartment selling prices in Queens, NY. You will be responsible for:

\begin{itemize}
\item gathering historical data including
\begin{itemize}
\item deciding which features (predictors) will be of use to you,
\item cleaning up data errors (if they exist),
\end{itemize}
\item deciding which model and which model-fitting technique to use
\item handling missing data (if they exist)
\item making predictions on apartments currently listed for sale
\end{itemize}

We will be using the \emph{raw data representation} found at \href{http://www.mlsli.com/}{MLSI}. The limitation on the data population for what \emph{you will be asked to predict} will be \qu{Queens, NY} as location and home types \qu{Condo / homeowner assoc.} and \qu{Co-op} up to a maximum sale price of \$1M.

You will be responsible for both (a) writing a report about your data science endeavors and (b) predictions for future data where you will be in competition with one another.

\subsection{Motivation}

I picked this project because I know you can all do better than \url{zillow.com} who make their own secret-sauce predictions that they whimsically call \qu{zestimates}. However, in Queens, zestimates are quite lame (e.g. \href{http://www.zillow.com/homes/recently_sold/Queens-New-York-NY/condo,apartment_duplex_type/2096496075_zpid/270915_rid/globalrelevanceex_sort/40.890158,-73.462143,40.452172,-74.200287_rect/10_zm/}{this one}). I imagine the collective brainpower of all of you plus the elementary concepts and tools from this class can produce better estimates.\footnote{At the very least, I imagine you can score a pretty good job interview at Zillow if your predictive performance is any good.}

\section{The Writeup}

\subsection{Gathering Data}

Your data will come from the following zip codes in mainland Queens.\footnote{For those of you who know Queens, we are leaving out the Rockaways, a peninsula near JFK airport that is geographically distinct from the rest of the neighborhoods.}

\begin{table}[htp]
\centering\small
\begin{tabular}{l|ccccccccc}
\hline
Northeast Queens		&11361& 11362,& 11363& 11364 \\
North Queens		&11354& 11355& 11356& 11357& 11358& 11359& 11360 \\
Central Queens		&11365& 11366& 11367 \\
Jamaica				&11412& 11423& 11432& 11433& 11434& 11435& 11436 \\
Northwest Queens	&11101& 11102& 11103& 11104& 11105& 11106 \\
West Central Queens	&11374& 11375& 11379& 11385 \\
Southeast Queens		&11004& 11005& 11411& 11413& 11422& 11426& 11427& 11428& 11429 \\
Southwest Queens	&11414& 11415& 11416& 11417& 11418& 11419& 11420& 11421 \\
West Queens			&11368& 11369& 11370& 11372& 11373& 11377& 11378 \\\hline
\end{tabular}
\end{table}

You can then enter all these zipcodes into an MLSI search, plus the Co-op and Condo and $\leq \$1$M restriction, or you can use my search in my account. \href{https://secure.mlsli.com/Account/CustomerLogin.aspx}{Login to MLSI} by using the login \texttt{kapelner@wharton.upenn.edu} and password \texttt{stat422} and then go to \href{http://www.mlsli.com/listing/listingsearch.aspx?ListingSearch=1455845}{this link} to load the saved search. As of the time of this writing, there are $\approx$1,200 sold properties. And under \qu{Status}, if you uncheck \qu{Sold} and check \qu{Active}, you will see $\approx$1,000 currently on the market. Of these, you will predict some of them (we will get to this part later).\\

As you can see, I'm not providing you with a CSV, JMP or RData file --- this is part of your job (and likely the most important part). This is too much work for one person to do. I suggest a number of things:

\begin{itemize}
\item team up early on
\item create shared google sheets where the information gets iteratively populated
\item use \url{MTurk.com} ... very easy way to crowdsource mini-jobs such as extracting data
\end{itemize}

In your writeup, you will write about your observations by

\begin{itemize}
\item indicating how many you have,
\item describing how you sampled them (and if this is not a simple random sample explain in detail why not) and
\item explaining the degree to which you feel this sample is representative of the population.
\end{itemize}

\noindent If I see no work done on this front by week two of the course, then I will divvy up responsibilities among the class.\\

\noindent Then, you will list the predictors you used and provide

\begin{itemize}
\item how many you have,
\item their names,
\item their data types,
\item a description of the information captured,
\item a report on missingness and the missingness mechanism and
\item a description about how the measurements were taken.
\end{itemize}

\textbf{There are no collaboration limits on this part of the project.} But you will be responsible for submitting an electronic copy of your data frame to canvas at the time that the project is due. (More details on upload specifics coming soon).

Building a dataset from scratch is a big job, but highly educational. You will see just how valuable creativity in this domain is and you will never look at data the same way again.

\subsection{Building a Model}

You should make use of any of the tools we covered in this class. Please, no methods or algorithms from outside the class.

In your writeup, you must explain the modeling choice you made and describe how you iteratively came to the model you will use for \qu{production} (that's lingo for the one you use to make your \qu{real-world predictions}). That means you will likely report model fit metrics such as likelihoods, AIC's, etc for a few different models. For the final model, you must report your in-sample and out-of-sample:

\begin{itemize}
\item $R^2$
\item MSE
\item RMSE
\item MAE
\end{itemize}

There are a few other things that need to be reported on:

\begin{itemize}
\item I will ask you to rank your most important predictors and explain how sensitive your model performance is if your predictor information were to vanish.

\item For the top three variables, how does your model's conditional mean change as the variable changes?

\item Which variables do you believe have an effect on sale price that is truly causal and why? Would you be able to prove it?

\item You will then be asked to comment on areas of covariate space that are in danger of extrapolation in your model.

\item I will ask you to comment on if there is any overfitting in your data.

\item Then, you will need to explain clearly how you handle missing data. If you are truly reporting out-of-sample performance metrics, you will have no problem when you predict real, future data that contains missing data.
\end{itemize}

\textbf{You will do this part of the project yourself with no collaboration.}

\section{The Prediction Competition}

You will then have one day to predict the selling prices of a 500 apartments currently on the market (found in the \href{https://docs.google.com/spreadsheets/d/12cOzcQlz9WCayasqB-sx_9E6gjQH0-eCuryqJUucZ50/edit#gid=0}{listing URLs} Google sheet). This list will be complete one week before the competition but not before then as we want to have the most up-to-date listings.

You will upload a file named \texttt{<Your Penn ID>.csv} to canvas by Friday, Feb 24 5PM. (More details on upload specifics coming soon). The number of lines in your CSV will be the same number of lines in the listing URLs sheet. Each line will consist of a single prediction value (in dollars without the dollar symbol or commas). For instance:

\begin{figure}[htp]
\begin{Verbatim}[frame=single, fontsize = \small]
145645
862684
452890
.
.
.
235977
\end{Verbatim}
\caption{An example file \texttt{<Your Penn ID>.csv}}
\end{figure}

I will then wait until the grading deadline. Approximately 8 apartments are sold per day. The listing URL sheet has 500 apartments representing about 1/6 of the market. Thus we can expect 1.3 apartments to sell per day and thus we will have about 18 data points to evaluate our future predictions against.

You will be graded on your out-of-sample $R^2$ value. How to allocate the points I have not determined yet.

If you finish in the top five among the two sections of Stat 422/722, I (or the TA) will try to reproduce your results via your submitted data frame and your crystal clear writeup explaining your modeling technique. Reproducible work / research is a becoming more and more demanded these days.

\end{document}


% !Mode:: "TeX:UTF-8"
% !TEX program  = xelatex
% The function of a paragraph indent is to mark a pause, setting the paragraph apart from what precedes it. If a paragraph is preceded by a title or subhead, the indent is superfluous and can therefore be omitted.

\section{Summary}
This chapter describes the mechanics of the publication process, which includes choosing a journal, submitting a manuscript, and the refereeing process. Strictly, your article can be called ``manuscript'' only after submitting, and ``paper'' only after it has been accepted for publication.
Moreover, the textbook proposes a valuable point: do not post articles that are not worth publishing.

\subsection{Choosing a Journal}
Submission is the next step after the article has been written and repeatedly revised, and choosing an appropriate journal is the most important thing before submission, which requires to consider the following factors: the length of the review time and the interval from receipt to publication.
Furthermore, the textbook tell us that do not pursue the reputation of a journal: the value of a paper is not being recognized when it is published, but being continually cited later.

\subsection{Submitting a Manuscript}
When finishing choosing the journal, you will enter the process of submission. Before submitting your manuscript, you should read carefully the instructions for authors that are printed in each issue of your chosen journal. Then you should write a cover letter and deliver it with your manuscript to the chosen journal.
In addition, most of the requirements are common sense and are similar for each journal, please see page 129 in \emph{Handbook of Writing for the Mathematical Science} for more information.

\subsection{The Refereeing Process}
If a manuscript is submitted to ``The Editor'' of the chosen journal, it is passed on to the editor-in-chief, who assigns it to a member of the editorial board. Then the chosen editor writes to two or more people asking them to referee the manuscript, suggesting a deadline about six weeks from the time they receive the manuscript. Finally, when all the referee reports have been received, the editor decides the fate of the manuscript, informs the author, and notifies the journal.

If you receive a rejection letter for any reason, you should treat it objectively. At this point, you have three options: 1) When the content of your article does not meet the chosen journal field, consider submitting it to other journals; 2) Modify your article according to the review comments and then submit it again; 3) Write a rebuttal to the editor to prove why the reviewer is wrong.

% \nocite{2013数学之英文写作,Nicholas1998Handbook}
% \bibliography{ref}


\documentclass[12pt]{amsart}
\usepackage{geometry} % see geometry.pdf on how to lay out the page. There's lots.
\geometry{a4paper} % or letter or a5paper or ... etc
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{amsmath}
\usepackage{amsaddr}
\usepackage{dirtytalk}
\usepackage{float}
\usepackage{listings}
\usepackage{hyperref}
\usepackage{enumerate}

\usepackage{color}

\definecolor{codegreen}{rgb}{0,0.6,0}
\definecolor{codegray}{rgb}{0.5,0.5,0.5}
\definecolor{stringcolor}{rgb}{0.7,0.23,0.36}
\definecolor{backcolour}{rgb}{0.95,0.95,0.92}
\definecolor{keycolor}{rgb}{0.007,0.01,1.0}
\definecolor{itemcolor}{rgb}{0.01,0.0,0.49}

\hypersetup{
    colorlinks=true,
    linkcolor=blue,
    filecolor=blue,
    urlcolor=blue,
}

\lstdefinestyle{mystyle}{
    %backgroundcolor=\color{backcolour},
    commentstyle=\color{codegreen},
    keywordstyle=\color{keycolor},
    numberstyle=\tiny\color{codegray},
    stringstyle=\color{stringcolor},
    basicstyle=\footnotesize,
    breakatwhitespace=false,
    breaklines=true,
    captionpos=b,
    keepspaces=true,
    numbers=left,
    numbersep=5pt,
    showspaces=false,
    showstringspaces=false,
    showtabs=false,
    tabsize=2
}

\lstset{style=mystyle}

\lstdefinelanguage{Swift}{
  keywords={associatedtype, class, deinit, enum, extension, func, import, init, inout, internal, let, operator, private, protocol, public, static, struct, subscript, typealias, var, break, case, continue, default, defer, do, else, fallthrough, for, guard, if, in, repeat, return, switch, where, while, as, catch, dynamicType, false, is, nil, rethrows, super, self, Self, throw, throws, true, try, associativity, convenience, dynamic, didSet, final, get, infix, indirect, lazy, left, mutating, none, nonmutating, optional, override, postfix, precedence, prefix, Protocol, required, right, set, Type, unowned, weak, willSet},
  ndkeywords={class, export, boolean, throw, implements, import, this},
  sensitive=false,
  comment=[l]{//},
  morecomment=[s]{/*}{*/},
  morestring=[b]',
  morestring=[b]"
}

\lstset{emph={Int,count,abs,repeating,Array}, emphstyle=\color{itemcolor}}

\title{Week 03}

\date{\today}

\lstset{style=mystyle}

%%% BEGIN DOCUMENT
\begin{document}
\maketitle

\section{Preparation for Assignment}
If, and \textit{only if} you can truthfully assert the truthfulness of each statement below are you ready to start the assignment.
\subsection {Reading Comprehension Self-Check}
\begin{itemize}
  \item I know that \textit{brute force} is a straightforward approach to solving a problem, usually directly based on the problem statement and definitions of the concepts involved.
  \item I understand that a first application of the brute-force approach often
    results in an algorithm that can be improved with a modest amount of effort.
  \item I know \textit{why} it is \textbf{false} to say that a strength of the brute-force
    approach is subpar algorithmic efficiency.
  \item I understand that \textit{exhaustive search} is a brute-force approach to combinatorial problems that suggests generating each and every combinatorial object of the problem, selecting those of them that satisfy all the constraints, and then finding a desired object.
  \item I know why it is \textbf{false} to say that exhaustive search is practical for all but very small instances of problems it can be applied to.
  \item I have reviewed Appendix A specifically focusing on understanding the formulas and rules for summations.
  \item I have studied and pondered these common algorithms and understand why they have the time efficiencies they do:
  \begin{itemize}
    \item Finding the maximum element in an array.
    \item Determining the uniqueness of all elements of an array.
     \item Multiplying two $n$-by-$n$ matrices.
     \item Converting a base 10 number to binary.
  \end{itemize}
\end{itemize}
\subsection{Memory Self-Check}

\subsubsection{Algorithm Efficiency Calculation}

Create brute force algorithms for each of these three situations:
\begin{enumerate}
     \item Computing $a^n$, where $a$ is positive and $n$ is a nonnegative integer.
     \item Computing $n!$.
     \item Sequential search.
\end{enumerate}.
Determine $\mathcal{O}$, $\Omega$, $\Theta$, input size, and time efficiency for each algorithm.

\section{Week 02 Exercises}
\subsection{ Exercise 1 on page 102}
\subsection{Exercise 8 on page 103}
\subsection{Exercise 6 on page 114}
\subsection{Exercise 4 on page 128}
\subsection{Exercise 8 on page 129}
\subsection{Find the Door}
You are facing a wall that stretches infinitely in both directions. There is a door in the wall, but you know neither how far away nor in which direction. You can see the door only when you are right next to it. Design and write code for an algorithm that enables you to reach the door by walking at most $\mathcal{O}(n)$  steps where $n$ is the (unknown to you) number of steps between your initial position and the door. (Hint: walk alternately right and left going each time exponentially farther from your initial position.)

\section{Week 02 Problems}
\subsection{Exercise 14 on page 103}
\subsection{Exercise 5 on page 129} Make sure you do a rigorous mathematical proof.
\subsection{Exercise 6 on page 121} Write code for this algorithm.

\end{document}


\documentclass[11pt, letterpaper]{article}
\setlength{\parindent}{0in}
\setlength{\textheight}{8.7in}
\setlength{\textwidth}{6.8in}
\setlength{\oddsidemargin}{-0.3in}
\setlength{\evensidemargin}{0.0in}
\addtolength{\topmargin}{-1in}
\setlength{\parskip}{0.1in}

\usepackage{amsmath, amsfonts, amssymb, color}
\usepackage{bm}
\usepackage{booktabs}
\usepackage{enumerate}
\usepackage{graphicx}
\usepackage{pdfpages}
\newcommand*{\justifyheading}{\raggedleft}

\renewcommand{\baselinestretch}{1.0}

\newcommand{\bx}{{\bm x}}
\newcommand{\bX}{{\bm X}}
\newcommand{\by}{{\bm y}}
\newcommand{\bY}{{\bm Y}}
\newcommand{\bW}{{\bm W}}
\newcommand{\bG}{{\bm G}}
\newcommand{\bR}{{\bm R}}
\newcommand{\bZ}{{\bm Z}}
\newcommand{\bV}{{\bm V}}
\newcommand{\bL}{{\bm L}}
\newcommand{\bz}{{\bm z}}
\newcommand{\be}{{\bm e}}
\newcommand{\bgamma}{{\bm \gamma}}
\newcommand{\bbeta}{{\bm \beta}}
\newcommand{\balpha}{{\bm \alpha}}
\newcommand{\bSigma}{{\bm \Sigma}}
\newcommand{\bmu}{{\bm \mu}}
\newcommand{\btheta}{{\bm \theta}}
\newcommand{\bepsilon}{{\bm \epsilon}}
\newcommand{\bone}{{\bm 1}}
\newcommand{\bzero}{{\bm 0}}
\newcommand{\bC}{{\bm C}}
\newcommand{\bI}{{\bm I}}
\newcommand{\bA}{{\bm A}}
\newcommand{\bB}{{\bm B}}
\newcommand{\bQ}{{\bm Q}}
\newcommand{\bS}{{\bm S}}
\newcommand{\bD}{{\bm D}}
\newcommand{\cQ}{\mathcal{Q}}
\newcommand{\cU}{\mathcal{U}}
\newcommand{\cI}{\mathcal{I}}
\newcommand{\cL}{\mathcal{L}}

\newcommand{\beas}{\begin{eqnarray*}}
\newcommand{\eeas}{\end{eqnarray*}}

\newenvironment{equationarrayright}{
                          \begin{eqnarray*}
                          \begin{array}{rcll}
                         }{
                          \end{array}
                          \end{eqnarray*}
                         }
\newcommand{\bear}{\begin{equationarrayright}}
\newcommand{\eear}{\end{equationarrayright}}

\renewcommand\arraystretch{1.3}

\DeclareMathOperator*{\argmin}{arg\,min}

\title{STAT/BIOST 571: Homework 4}
\author{Philip Pham}
\date{\today}

\begin{document}

\maketitle

\section*{Problem 1: Iterative methods for solving GEE (10 points)}

{\em In this problem, you will compare
variants on GEE (or general linear model) estimation procedures when applied to the example dental data set for the model on slide 2.71.
Throughout, use a homoscedastic AR-1 working covariance matrix and estimate $\alpha$ and $\sigma^2$
using moment-based estimators.
For each procedure, compute point estimates and robust sandwich-based standard errors that account for clustering.  Where applicable, report how many interations are required to get convergence of all estimates
($\bbeta$, $\alpha$, and $\sigma^2$) in their 1st/2nd/3rd significant figures.}
\begin{enumerate}[(a)]
{\em \item Use the non-iterative procedure we have employed previously; that is, first estimate $\bbeta$ by OLS, then estimate the covariance parameters based on residuals from the OLS fit, and then restimate $\bbeta$
  using the updated working covariance matrix. }

\begin{description}
\item[Solution:] The covariance structure for each cluster $i$ is assumed to be
  the $m_i \times m_i$ matrix $\Sigma_i$, where $\Sigma_{ijj} = \sigma^2$ and
  $\Sigma_{ijk} = \sigma^2\alpha^{\left\lvert j - k\right\rvert}$.

  Given a working estimate of $\beta$, say $\hat{\beta}^{(t)}$, we compute
  working covariance matrices for each cluster
  \[\hat{\Sigma}_i^{(t + 1)} = \left(y_i - X_i\hat{\beta}^{(t)}\right)\left(y_i -
      X_i\hat{\beta}^{(t)}\right)^\intercal.\] We get working estimates of the
  covariance parameters $\alpha$ and $\sigma^2$:
  \begin{align*}
    \left(\hat{\sigma}^2\right)^{(t + 1)}
    &= \frac{1}{\sum_{i=1}^nm_i}\sum_{i=1}^n\sum_{j=1}^{m_i}\hat{\Sigma}_{ijj}^{(t + 1)} \\
    \hat{\alpha}^{(t + 1)}
    &= \frac{1}{\left(\hat{\sigma}^2\right)^{(t + 1)}\sum_{i=1}^n\left(m_i - 1\right)}
      \sum_{i=1}^n\sum_{j=1}^{m_i-1}\hat{\Sigma}_{i,j,j+1}^{(t + 1)}.
  \end{align*}

  Let $\hat{V}^{(t+1)}$ be the matrix where
  $\hat{V}_{ij}^{(t+1)} = \left(\hat{\sigma}^2\right)^{(t+1)}
  \left(\hat{\alpha}^{(t+1)}\right)^{\lvert j - i\rvert}$. Let
  $\hat{W}^{(t+1)} = \left(\hat{V}^{(t+1)}\right)^{-1}$.

  Then, we
  can get an updated estimate of $\beta$:
  \begin{equation}
    \hat{\beta}^{(t+1)} =
    \left(
      \sum_{i=1}^n X_i^\intercal \hat{W}^{(t+1)} X_i
    \right)^{-1}
    \left(
      \sum_{i=1}^n X_i^\intercal \hat{W}^{(t+1)} y_i
    \right).
  \end{equation}

  We can compute the covariance of this estimate with the sandwich estimate:
  \begin{equation}
    \small
    \hat{\operatorname{cov}}\left(
      \hat{\beta}^{(t+1)}
    \right) =
    \left(
      \sum_{i=1}^n X_i^\intercal \hat{W}^{(t+1)} X_i
    \right)^{-1}
    \left(
      \sum_{i=1}^n X_i^\intercal \hat{W}^{(t+1)}
      \hat{\Sigma}^{(t+1)}
      \hat{W}^{(t+1)}
      X_i
    \right)
    \left(
      \sum_{i=1}^n X_i^\intercal \hat{W}^{(t+1)} X_i
    \right)^{-1},
    \label{eqn:sandwich_estimate}
  \end{equation}
  where \[
    \hat{\Sigma}^{(t+1)} = \frac{1}{n}\sum_{i=1}^n
    \left(y_i - X_i\hat{\beta}^{(t+1)}\right)
    \left(y_i - X_i\hat{\beta}^{(t+1)}\right)^\intercal,
  \]
  since we assume all clusters have the same covariance structure.

  To obtain $\hat{\beta}^{(0)}$, we let $\hat{W}^{(0)} = I$. This is the OLS
  esimate. See Table \ref{tab:beta0_estimate} for the estimate and standard
  errors.

  \begin{table}
    \centering
    \input{beta0_estimate.tex}
    \caption{Estimate of $\beta$ using OLS. Standard errors were estimated using
      Equation \ref{eqn:sandwich_estimate}.}
    \label{tab:beta0_estimate}
  \end{table}

  With this estimate, we obtain $\hat{\alpha}^{(1)} = 0.61136$ and
  $\left(\hat{\sigma}^2\right)^{(1)} = 4.90516$, which allows us to use
  $\hat{W}^{(1)}$ to get a new estimate of $\beta^{(1)}$. See Table
  \ref{tab:beta1_estimate}.

  \begin{table}
    \centering
    \input{beta1_estimate.tex}
    \caption{$\hat{\beta}^{(1)}$ is an updated estimates for $\beta$.}
    \label{tab:beta1_estimate}
  \end{table}

\end{description}

{\em \item Iterate the procedure in part (a), as suggested on slide 2.44.}

\begin{description}
\item[Solution:] The final converged estimates can be found in Table
  \ref{tab:beta_final_estimate}.
  \begin{table}[!ht]
    \centering
    \input{beta_final_estimate.tex}
    \caption{Final converged estimates for $\beta$.}
    \label{tab:beta_final_estimate}
  \end{table}

  For the covariance parameters, we found $\hat{\alpha} = 0.61353$ and
  $\hat{\sigma}^2 = 4.91065$.

  It took only one iteration to find convergence in the first significant digit
  ($\hat{\beta}^{(1)}$). Already by the second iteration ($\hat{\beta}^{(2)}$),
  we have convergence in the second and third significant digits.
\end{description}
\end{enumerate}

\pagebreak
\section*{Appendix}

Code to produce tables is attached.

\pagebreak

\includepdf[pages=-]{iterative_gee_dental.pdf}

\end{document}