\section{2021-09-22 Lecture}

This is a class that cannot fail,
because if it crashes and burns,
the qualifier fails.

This is my favourite lecture.
Sorry it's online.
It's conceptual.
This used to not be covered in standard classes,
but it because so popular there's no way out.
I'm going to start from something everyone knows.
The double slit experiment.

If you're not comfortable,
it means two things:
you don't know QM and you should laern straight away.

The best way to learn is to open the old Feynman lectures on physics.
Of course you can go to Youtube anddo the same thing,
with beautiful computer graphics,
but unfortanaltely many of them are wrong.
Feynman knows physics.

If there's only one hole nothing exciting happens.
The particle hits the screen,
mostly behind the hole.
Here I plot the number of particles that hit the screen.
If the hole is left,
you get particles on the lfet.
If the hole is right,
you get particles on the right.

Buty what happens when you shoot two holes?
They interferer with each other.
The result is surpricingly,
in fact the most likely place to get a particle is in the middle,
which is neither the single hole scneairos.
It's more than just the sum of the two.
You get an interference pattern.

You seen t his before.
It's pretty.
There are regions where the waves interfere desctructively and you don't get a
particle behin the screen.
that's how all waves behave.
If you make waves no thel ake,you get he same thing,
so it's not surprising.
What is surprising is tat the aprticles sometimes behave like particles,
and sometimes waves.
In fact,
what you get on the screen is this.

If you send particles one by one and you start counting,
every time you send a particle,
you get one spot on the screen,
however the probability fo getting apricles obeys the interference pattern.
That's this other way we see this particle-wave duality.

I'm going to switch to my laptop.
That's a drawing of the situation here.
I want to remind you how to descrbie this quanutm mechancially.

Let's say the left sitautions is $\ket{L}$
and the situation for the right hole open is $\ket{R}$.
When you have both holes open,
the state is going to be a linear combination
\begin{align}
    \ket{\psi} = \alpha\ket{L} + \beta\ket{R}
\end{align}
How do you get intference?
Let's measure $A_y$ that counts the number of particles,
or the probablity of the particle arriving at coordinate $y$
on hte screen.
Of course,
I want to take the expectation value.
\begin{align}
    \bra{\psi} A_y \ket{\psi} &=
    \left( \alpha^* \bra{L} + \beta^*\bra{R} \right)
    A_y
    \left( \alpha\ket{L} + \beta\ket{R} \right)\\
    &=
    |\alpha|^2 \bra{L}A_y\ket{L}
    + |\beta|^2 \bra{R}A_y\ket{R}
    + \alpha\beta^* \bra{L}A_y\ket{R}
    + \alpha^*\beta \bra{R}A_y\ket{L}
\end{align}
The first two terms are familiar.
They are just the probabilities for if the left hole is open only
and the rigt hole is open only respectively.
THe novelty of course in QM is that you have inerference terms,
the last two terms.
While the $|\alpha|^2$ and $|\beta^2|$ terms are positive,
those $\alpha\beta^*$ and $\beta\alpha^*$ terms are not necessarily positive,
so it's possible you cna have cancelation.
And that's why you get zeros in the distribution,
it's because of intereference and cancellation.

So this is well known.
The fact you have uqanutm intereference out of linear combinations,
you get this pretty well.

Let's compare this with a different situation.
Let's say I have a different siuaiton like this.
Except the two slits are never open at the same time.

I'm going to trow a dice.
If the number is odd,
I open the left hole.
If the number is even,
I open the right hole.
What am I going to get?

hal the time I'm going to get the L distributino,
and half the time I'm going to ge the R distribution.
And I get a double-bump distirbution.

So then this quantity,
The previous situation would be left AND right.
But now I will call this dice roll situation left OR right.
\begin{align}
    \bar{A}_y &=
    p_L \bra{L}A_y\ket{L}
    + p_R \bra{R}A_y\ket{R}
\end{align}
where $p_L$ and $p_R$ are the probabilities of having the left or right holes
open respectively.
You notice that this matces the first two terms of the previous formula.
What you do not find is the second two terms,
so there is no interference.
This is a different physical sitaution.

Those two things are not the same.
If you plot $A_y$ vs $y$,
in the QM superposition,
you get this
[picture]

But if you have the classical probability,
you get two bumps.
[picture]

These two sitautions are very common,
and you need to give these names.
having L and R in superpsotiion quantum mechanically,
we have a \emph{coherent} sum.
But the classical probability situation,
is the \emph{incoherent sum}.
The incorhernet sitaution happens all the time
in classical physics.

But the coherent sum is something very special to QM,
there is no classical analogue for that.

This situation where you have a combination of this,
where some of it is quanutm mehaonical,
but I also don't know what the wave function is,
appears commonly in physics too.

So ther eare two kinds of uncertainty.
There is the quantum uncertainty of the wave function,
butther'es the classical uncertainty of not knowing what the wave function is in
the first place.
There is a formalism to deal with this.

Suppose you have some observablve $A$.
Then
\begin{align}
    \bar{A} &=
    \underbrace{
    \sum_n \underbrace{p_n}_{\text{prob. in $\ket{n}$}} \underbrace{\bra{n} A \ket{n}}_{\text{quantum average}}
    }_{\text{classical average}}
\end{align}
So we have a quantum and a classical average

There's a cute way to write this as a trace.
\begin{align}
    \bar{A} = \Tr\left[
    \left( \sum_n p_n \ket{n}\bra{n} \right) A
    \right]
\end{align}
Is this the same?
It's easy to see,
because to compute the trace,
one way of computing the trace is to take a basis,
for example the same basis $\ket{n}$,
then compute the sandwich of whatever is in the trace and then sum over elements
of the basis,
but you see this is easy to compute.
\begin{align}
    \Tr\left[
    \left( \sum_n p_n \ket{n}\bra{n} \right) A
    \right]
    &=
    \sum_{m} \bra{m}
    \sum_n p_n \ket{n}\bra{n} A\ket{m}\\
    &= \sum_{m,n} \cdots
\end{align}
Then observe the following things.
Then we call that part the density matrix.
\begin{align}
    \rho = \sum_n p_n \ket{n}\bra{n}
\end{align}
This contains all the information about the system.
It doesn't tell me what the wave function is,
because there's uncertainty about what the wave function is.
But the probabliies are al defined by this $\rho$.
States whree therare different clasical probailitesi of different wave fucntions
is called a \emph{mixed state}.
In situations wher we know what hte wave function is,
they are called \emph{pure dstates}.

To be clear,
\begin{align}
    \bar{A} = \Tr(\rho A)
\end{align}
Remember $\rho$ contains informaiton about all possible wave functions the
system may have.

Are we good up to now?
By the way,
you can raise a question by raising a hand,
but it's better to shout,
just unmute yourself and shout.
You can even go and ask questions in the chat.

\begin{question}
    Can you elaborate on mixed state?
\end{question}
If you know thw ave function of the sytem,
you call it a pure state,
that's what you learnt in QM so far.
A pure state is just a real state.
But then suppose you have a harmonic oscillator
with 30\% chance in the ground state and 70\% chance in the first excited state,
that is a mixed state.
You should not be confused though.
Take hte harmonic oscilator for exmaple.
\begin{align}
    \ket{\varphi} &=
    \frac{3}{5}\ket{0}
    + \frac{4}{5}\ket{1}
    \ne
    \rho
    =
    \left( \frac{3}{5} \right)^2 \ket{0}\bra{0}
    \left( \frac{4}{5} \right)^2 \ket{1}\bra{1}
\end{align}
These states here have the same probabiliteis,
but they are completely different states.
I can even add a phase.
\begin{align}
    \ket{\varphi} &=
    \frac{3}{5}\ket{0}
    + i\frac{4}{5}\ket{1}
    \ne
    \rho
    =
    \left( \frac{3}{5} \right)^2 \ket{0}\bra{0}
    \left( \frac{4}{5} \right)^2 \ket{1}\bra{1}
\end{align}
It's either one or the other.
No matter how smart I am,
I will know a way to measure.

here's an example.

How do we describe th sitaution where both holes are open.
We already have that,
a quantum superpsoition of left and right.
When I compuet the probablity of getting a particle on the sreen,
I get interference tersm.
If I have a phsae,
the probabilities $|\alpha|^2$ and $|\beta|^2$ don't change,
but I get a different interefernece pattern.

That's usual quantum mechanics,
but I can describe the sitaution with desity matrices too
which account for probabilities that arise because I am too dumb to know.

So I can describe the double slit experiment with density matrices too.
For example,
the incoehreent sum is
\begin{align}
    \rho &= \frac{1}{2} \ket{L}\bra{L}
    + \frac{1}{2}\ket{R}\bra{R}
\end{align}
and you can computet the probabilities
\begin{align}
    \bar{A} &=
    \Tr(\rho A_y)\\
    &=
    \Tr\left( \frac{1}{2}\ket{L}\bra{L} + \frac{1}{2}\ket{R}\bra{R} \right) A\\
    &=
    \bra{L}\left(
    \frac{1}{2} \ket{L}\bra{L}
    + \frac{1}{2} \ket{R}\bra{R}
    \right)A_y
    \ket{R}
    + \bra{L}\left(
    \frac{1}{2} \ket{L}\bra{L}
    + \frac{1}{2} \ket{R}\bra{R}
    \right)A_y
    \ket{R}\\
    &= \frac{1}{2}\bra{L} A_y \ket{L}
    + \frac{1}{2}\bra{R} A_{y} \ket{R}
\end{align}
Now look at what we thoguht it should be
\begin{align}
    \bar{A}_
    &= p_L\bra{L} A_y \ket{L}
    + p_R\bra{R} A_{y} \ket{R}
\end{align}
so the formalism works!
Let me tell you a couple of probabilities it's to satisfy.

Firstly, $\rho$ is a Hermitian operator.
It's weird,
because it's not an observable,
but it's the state of the system.
\begin{align}
    \rho^{\dagger} = \rho
\end{align}
Can you see this is true?
Sure
\begin{align}
    \left( \sum_n p_n \ket{n}\bra{n} \right)^{\dagger}
    &= \sum_n p_n^* \ket{n}\bra{n}\\
    &= \sum_n p_n \ket{n}\bra{n}
\end{align}
because $p_n$ are real probabilities,
so very straighforward.

Anotherp robability isthat it has unit trace.
\begin{align}
    \Tr \rho = 1
\end{align}
To see this,
\begin{align}
    \Tr \rho &=
    \Tr \sum_n p_n\ket{n}\bra{n}\\
    &= \sum_m \bra{m} \sum_n p_n\ket{n}\bra{n} \ket{m}\\
    &= \sum_{n,m} p_n \braket{m}{n} \braket{n}{m}\\
    &= \sum_n p_n\\
    &= 1
\end{align}
because the total probability is equal to 1.

Finally, $\rho$ is positive definite.
It follows from the fact that $p_n$ has to be positive or zero.
Positive definite means that
\begin{align}
    \bra{\phi}\rho\ket{\phi} &=
    \bra{\phi} \sum_n p_n\ket{n}\braket{n}{\phi}\\
    &=
    \sum_n p_n \braket{\phi}{n} \braket{n}{\phi}\\
    &= \sum_n p_n |\braket{n}{\phi}|^2\\
    &\ge 0
\end{align}

There's one final property.
For some special states, we have
\begin{align}
    \rho^2 = \rho
\end{align}
if and only if $\rho=\ket{\psi}\bra{\psi}$ is a pure state.
You can see this clearly because if
$\rho = \sum_n p_n \ket{n}\bra{n}$
and if $p_n=0$ except $p_{\bar{n}}=1$,
then obviously $\ket{\bar{n}}=\ket{n}$.
There are two things to prove,
because it's if and only if.
It's a simple test.
Suppose $\rho$ is pure,
then
\begin{align}
    \rho^2 &=
    \ket{\psi}\braket{\psi}{\psi}\bra{\psi} = \rho
\end{align}
It's a bit of extra work to go the other way around.

Suppose $\rho^2 = \rho$.
Then
\begin{align}
    \sum_n p_n \ket{n}\bra{n}
    \sum_m p_m \ket{m}\bra{m}
    &= \sum_{n,m} p_n p_m \ket{n}
    \underbrace{\braket{n}{m}}_{\delta_{nm}} \bra{m}\\
    &= \sum_n p_n^2 \ket{n}\bra{n}\\
    &= \sum_n p_n \ket{n}\bra{n}
\end{align}
so we know that $p_n^2=p_n$ for all $n$.
There are only two ways this can be true.
Either $p_n=0$ or $p_n=1$.
But probabilities sum to 1,
so only one of these can be $p_{\bar{n}}=1$,
and all the other $p_n=0$.
What does that prove?
In other words,
\begin{align}
    \rho = \sum_n p_n\ket{n}\bra{n} = \ket{\bar{n}}\bra{\bar{n}}
\end{align}

Oh there's a question.
It's just one word: magical.

You're just in awe of the power of density matrices and bras and kets?

By the way,
Landau invented density matrices.
He was two years too young to invent QM,
but he invented density matrices.
Bras and kets,
I'm tired of syaing it's a beautiful thing,
but I hope you can appreciate how the algebra just works without thinking.
It's importnat to understand why it works,
but once you do,
it's easy.

The name of this class is quantum and statistical physics.
Forgoet about the deep stuff.y
You're goign to use distributions of positions and momentum classical,
but the density analogue is density matrices,
where you have distributions over wave functions.

\begin{question}
    So $\rho$ is diagonal?
\end{question}
Well $\bra{n}\rho\ket{n'}$ is a diagonal matrix in this basis,
but in a different basis,
it will not necessarily be a diagonal matrix,
despite describing the same physics.
If the operator was diagonal,
I wouldn't talk about htis operator,
it would be overkill.
In this basiss to define $\rho$,
but may be diagonal,
but in another basis,
it's not diagonal
and it's not obvoius at all it's not a pure state.


\documentclass{report}

\usepackage[margin=1in]{geometry}
\usepackage{graphicx}

\title{Assignment 3\\kMeans Clustering\\[1em]CSCI 479}
\author{Josh Tan}
\date{November 14, 2013}
\setlength\parindent{0pt}

\graphicspath{{Results/}}
\DeclareGraphicsExtensions{.pdf}

\begin{document}
\maketitle

\section*{twoCircles}

\begin{verbatim}
Cluster 1:
        Mean: 3.99267174570399, 1.97062519340629
        Size: 1000
Cluster 2:
        Mean: 4.05552650036302, 5.9599730477341
        Size: 1000
Iteration Count: 4
Final Delta: 0
\end{verbatim}

\begin{figure}[htp!]
  \centering
  \includegraphics[width=0.9\linewidth]{twoCircles}
%  \caption{Final clustering for twoCircles dataset.}
\end{figure}

\pagebreak

\section*{fourCircles}

\begin{verbatim}
Cluster 1:
        Mean: 3.05207118383164, 3.09147626141166
        Size: 500
Cluster 2:
        Mean: 0.954808255061881, 3.08582099204835
        Size: 500
Cluster 3:
        Mean: 0.974412348734461, 0.988705179423637
        Size: 500
Cluster 4:
        Mean: 3.07441234873446, 0.988705179423637
        Size: 500
Iteration Count: 6
Final Delta: 0.0008994456
\end{verbatim}

\begin{figure}[htp!]
  \centering
  \includegraphics[width=0.9\linewidth]{fourCircles}
%  \caption{Final clustering for fourCircles dataset.}
\end{figure}

\pagebreak

\section*{twoEllipses}

\begin{verbatim}
Cluster 1:
        Mean: 2.66714969798415, 4.59020220218321
        Size: 985
Cluster 2:
        Mean: 5.19959310439594, 4.59612460134661
        Size: 1015
Iteration Count: 7
Final Delta: 0.0009776696
\end{verbatim}

\begin{figure}[htp!]
  \centering
  \includegraphics[width=0.9\linewidth]{twoEllipses}
%  \caption{Final clustering for twoEllipses dataset.}
\end{figure}

\pagebreak

\section*{iris}

\begin{verbatim}
Cluster 1:
        Mean: 6.85384615384615, 3.07692307692308, 5.71538461538462, 2.05384615384615
        Size: 39
Cluster 2:
        Mean: 5.006, 3.418, 1.464, 0.244
        Size: 50
Cluster 3:
        Mean: 5.88360655737705, 2.74098360655738, 4.38852459016393, 1.4344262295082
        Size: 61
Iteration Count: 3
Final Delta: 0
\end{verbatim}

\begin{figure}[htp!]
  \centering
  \includegraphics[width=0.9\linewidth]{iris}
%  \caption{Final clustering for iris dataset.}
\end{figure}

\pagebreak

\section*{t4.8k}

\begin{verbatim}
Cluster 1:
        Mean: 128.878859446888, 110.79153910676
        Size: 1864
Cluster 2:
        Mean: 531.905322370123, 208.456487307692
        Size: 897
Cluster 3:
        Mean: 393.100021033058, 234.425285651974
        Size: 1089
Cluster 4:
        Mean: 341.628938318801, 96.8454311968665
        Size: 1468
Cluster 5:
        Mean: 526.594384030047, 92.6984573173709
        Size: 1065
Cluster 6:
        Mean: 206.521799135436, 227.93723994496
        Size: 1617
Iteration Count: 18
Final Delta: 0
\end{verbatim}

\begin{figure}[htp!]
  \centering
  \includegraphics[width=0.78\linewidth]{t4_8k}
%  \caption{Final clustering for t4.8k dataset.}
\end{figure}

\end{document}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:


This section presents our results. The first sub-section contains summary statistics regarding the variability of six key covariates pre- and post- adjustment to address measurement error. The second sub-section contains covariate balance diagnostics. The third sub-section contains our primary ETC results, presenting our estimates of the treatment effect and a series of sensitivity analyses. The final sub-section contains our analysis of covariate importance and investigation into treatment effect heterogeneity.

\subsection{Covariate adjustment}

We first examine the effects of our covariate adjustments on the variance of our pre-treatment outcomes and pre-treatment unemployment rates among the expansion states. We most heavily prioritize balancing these covariates, but they are also among the least precisely estimated (all of our other covariates average over three years of data, rather than just one). Table~\ref{tab:adjust1} displays the variance of each covariate on the unadjusted and adjusted datasets. We see that both the homogeneous and heterogeneous adjustment procedures reduce the variability in the data by comparable amounts. Intuitively, the adjustment to address measurement error reduces the likelihood that our balancing weights will over-fit to noise in the data. These results are consistent across most of our other covariates.

\begin{table}[ht]
\caption{Sample variance on unadjusted and adjusted datasets, expansion states}
\label{tab:adjust1}
\begin{tabular}{lrrr}
  \hline
Variable & No adjustment & Heterogeneous & Homogeneous \\
  \hline
Uninsured Pct 2011 & 8.35 & 8.04 & 8.05 \\
  Uninsured Pct 2012 & 8.20 & 7.89 & 7.90 \\
  Uninsured Pct 2013 & 8.09 & 7.78 & 7.79 \\
  Unemployed Pct 2011 & 3.66 & 3.25 & 3.27 \\
  Unemployed Pct 2012 & 3.72 & 3.38 & 3.38 \\
  Unemployed Pct 2013 & 3.20 & 2.88 & 2.87 \\
   \hline
\end{tabular}
\end{table}

\subsection{Covariate balance}

Figure~\ref{fig:loveplotc1} displays the reduction of imbalances using our H-SBW weights. This plot only displays covariates with greater than one percentage point difference between the targeted mean in the expansion region and the mean values in the non-expansion region prior to weighting, and the reweighted treatment values use our preferred covariate adjustment $\hat{\eta}_1(W_{sc})$. Before applying our weights, we see that there are substantial imbalances in the Republican governance indicators, as well as pre-treatment uninsurance and unemployment rates. Our weights reduce these differences; however, some remain, particularly among the Republican governance indicators. A complete balance table is available in Appendix D, Table~\ref{tab:baltab1}.

\begin{figure}[H]
\begin{center}
    \caption{Balance plot, primary dataset}
    \label{fig:loveplotc1}
    \includegraphics[scale=0.6]{01_Plots/balance-plot-etuc1.png}
\end{center}
\end{figure}

We also compare the H-SBW estimator to the SBW estimates in Figure~\ref{fig:sbwvhsbw1}. We see that H-SBW more evenly distributes the weights across states relative to SBW, particularly by reducing the amount of weight given to CPUMAs in Ohio.

\begin{figure}[H]
\begin{center}
    \caption{H-SBW versus SBW, weights summed by state, primary dataset}
    \label{fig:sbwvhsbw1}
    \includegraphics[scale=0.6]{01_Plots/weights-by-state-sbw-hsbw-c1.png}
\end{center}
\end{figure}

We then use ridge-regression augmentation to extrapolate from the data in order to reduce all imbalances within 0.5 percentage points. Figure~\ref{fig:statewghts} shows the total weights summed across states for two estimators: H-SBW and BC-HSBW. This figure sums the negative weights separately from the positive weights to show the extent of the extrapolation. We see that BC-HSBW extrapolates somewhat heavily in order to achieve the desired level of balance, particularly for CPUMAs in California.

\begin{figure}[H]
\begin{center}
    \caption{H-SBW versus BC-HSBW, weights summed by state, primary dataset}
    \label{fig:statewghts}
    \includegraphics[scale=0.6]{01_Plots/weights-by-state-hsbw-c1.png}
\end{center}
\end{figure}

Finally, we wish to see whether the weights generated using the unadjusted data balance the adjusted covariates. While this balance measure does not reflect the ``true'' imbalances, this comparison does give some indication of whether the unadjusted weights are overfitting to noisy covariate measurements. Table~\ref{tab:balcomp} compares the imbalances among our pre-treatment outcomes and uninsurance rates using H-SBW weights generated on our unadjusted dataset applied to the adjusted (homogeneous) dataset. The ``Unweighted Difference'' column represents the raw difference in means, while the ``Weighted Diff'' column reflects the weighted difference that we calculate on the unadjusted dataset. The ``Homogeneous Diff'' column displays the weighted imbalance when applying the H-SBW weights to the dataset using the homogeneous adjustment, and likewise for ``Heterogeneous Diff.'' We see that the weighted pre-treatment outcomes are approximately one percentage point lower than we desired in the two years prior to treatment using the heterogeneous adjustment, and -0.2 percentage points lower (on average) using the homogeneous adjustment. Given the high degree of correlation between pre-treatment outcomes, we may expect the estimator of $\psi^1$ trained on the unadjusted data to have some downward bias.

\begin{table}[ht]
\caption{Balance comparison: unadjusted weights on adjusted data}
\label{tab:balcomp}
\begin{tabular}{lrrrr}
  \hline
Variables & Unweighted Diff & Weighted Diff (none) & Homogeneous Diff & Heterogeneous Diff\\
  \hline
Uninsured Pct 2011 & -3.09 & -0.05 & -0.11 & 0.92 \\
  Uninsured Pct 2012 & -2.99 & -0.05 & -0.21 & -1.06 \\
  Uninsured Pct 2013 & -3.00 & -0.05 & -0.38 & -0.93
   \hline
\end{tabular}
\end{table}

\subsubsection{Model validation}

We compare the performance of our models by repeating the covariate adjustments and calculating our procedure on 2009-2011 ACS data to predict 2012 outcomes, and similarly for 2010-2012 data to predict 2013 outcomes for the treated states. Table~\ref{tab:pretxpred} see that the estimators trained on the covariate adjusted data have substantially better performance than the unadjusted data. Moreover, the estimators trained on the homogeneous adjustment seem to do slightly better than the ones that model the heterogeneity; we therefore prioritize presenting results on the homogeneous adjustment. We also find that SBW tends to have slightly lower bias than H-SBW. This is consistent with our theoretic results in Appendix A, which show that the bias should decrease with the square of the weights for fixed $X$. Despite these results, H-SBW may have lower variance (and possibly MSE) given our assumed dependencies in the model errors. We therefore do not use these results to prefer H-SBW or SBW. Finally, we see that the bias corrected estimators tend to perform worse in this application. This indicates that the extrapolation bias outweighs the cost of the covariate imbalances. While this does not necessarily imply this should hold for the model of $Y^1_T$, it does caution against these results. We see this as a function of our models as best reflecting an approximation: we expect in general that assuming the linear outcome models approximately holds on the support of the data where we have sufficient covariate overlap, but we these models may lead us astray when our weights extrapolate excessively from the data. The worst performing estimators are the bias-corrected estimators trained on the unadjusted data.

\begin{table}[ht]
\caption{Estimator pre-treatment outcome prediction error}
\label{tab:pretxpred}
\begin{tabular}{llrrr}
  \hline
Sigma estimate & Estimator & 2012 error & 2013 error & RMSE \\
  \hline
Homogeneous & SBW & -0.18 & -0.22 & 0.20 \\
  Homogeneous & H-SBW & -0.24 & -0.21 & 0.23 \\
  Heterogeneous & SBW & -0.25 & -0.30 & 0.27 \\
  Heterogeneous & H-SBW & -0.32 & -0.39 & 0.36 \\
  Homogeneous & BC-SBW & -0.42 & -0.35 & 0.39 \\
  Heterogeneous & BC-SBW & -0.45 & -0.39 & 0.42 \\
  None & SBW & -0.50 & -0.61 & 0.56 \\
  None & H-SBW & -0.52 & -0.61 & 0.57 \\
  Homogeneous & BC-HSBW & -0.53 & -0.62 & 0.58 \\
  Heterogeneous & BC-HSBW & -0.53 & -0.72 & 0.63 \\
  None & BC-SBW & -0.82 & -0.93 & 0.88 \\
  None & BC-HSBW & -0.93 & -0.99 & 0.96 \\
   \hline
\end{tabular}
\end{table}

Finally, we find a consistent negative bias across all of our estimators: that is, all of our models tend to under-predict the true uninsurance rate among the non-expansion states the subsequent year. If we believe that the sign of this bias will also afflict our estimates of $\bar{Y}^1$, then we should expect our treatment effect estimates to have downward bias (which would bias our estimates away from zero). That is, the true treatment effect may be smaller (closer to zero) in absolute magnitude than the estimated treatment effect. If we believe the bias will also have comparable magnitude, these results suggests that the true treatment effect will be approximately 0.2 to 0.5 percentage points closer to zero than the estimated effect.

\subsection{Primary Results}

Using H-SBW we estimate an effect of -2.33 (-3.49, -1.16) percentage points. The SBW results are almost identical with -2.35 (-3.65, -1.06) percentage points. Compared to the unadjusted data we see very similar estimates at -2.34 (-2.85, -1.82) percentage points for H-SBW and -2.39 (-2.95, -1.83) percentage points for SBW. We see that H-SBW reduces the confidence intervals relative to SBW. We also observe that using the adjusted covariate set appears to increases the width of the estimated confidence intervals. This increase in variability is expected because the adjustment procedure generally reduces the variability in the data, as we saw in Table~\ref{tab:adjust1}, thereby requiring that the balancing weights also increase in variability to achieve the desired level of balance. Importantly, this variance estimate conditions on the covariate adjustment, and does not take into account the randomness in this procedure, and may therefore understate the true uncertainty. When we recalculate the entire adjustment procedure, we find that the confidence intervals are of a comparable magnitude. The results are available in Appendix E.

When we add the bias-correction, the absolute magnitude of the point estimate decreases: we estimate -2.05 (-3.32, -0.79) percentage points for BC-HSBW and -2.00 (-2.98, -1.01) percentage points for BC-SBW. In contrast to the H-SBW and SBW estimators, we see that the confidence interval for BC-SBW is narrower than for BC-HSBW. Figure~\ref{fig:estimators} presents all of our estimates. All adjusted estimates were closer to zero than the unadjusted estimates, though the point estimates from the SBW and H-SBW were estimators were virtually identical. The heterogeneous adjustments were all closer to zero than the unadjusted estimates; results are available in Appendix E.

\begin{figure}[H]
\begin{center}
    \caption{Primary point estimates and confidence intervals}
    \label{fig:estimators}
    \includegraphics[scale=0.6]{01_Plots/point-estimates-c1.png}
\end{center}
\end{figure}

Lastly, we examine the robustness of our point estimates to the removal of individual states (these are the same point estimates used to calculate our confidence intervals). Figure~\ref{fig:loostateplot} shows how the point estimates for each estimator changes for both the (homogeneous) adjusted and unadjusted datasets. We see similar results in either case: removing Ohio tends to move the point estimates farther from zero (though the change is larger on the adjusted dataset). By contrast, removing North Dakota, Kentucky, or California tends to move the estimates closer to zero.

\begin{figure}[H]
\begin{center}
    \caption{Estimator sensitivity to states}
    \label{fig:loostateplot}
    \includegraphics[scale=0.6]{01_Plots/loostate-sensitivityc1-state-uu-i.png}
\end{center}
\end{figure}

\subsection{Sensitivity analysis} \label{sssec:sensitivity}

We now consider the sensitivity of our analysis with respect to no anticipatory treatment effects. Several states had partial limited expansions prior to 2014. Following \cite{frean2017premium}, these states are California, Connecticut, Minnesota, New Jersey, and Washington. We rerun our analyses excluding CPUMAs from all five of these states. We have no a priori expectation about how removing these states might affect our estimates: on the one hand, states that expanded early might have a smaller treatment effect after 2014 because they already enrolled newly eligible individuals. On the other hand, if these states were also more motivated to enroll people in Medicaid, they might have experienced larger post-expansion coverage gains. Figure~\ref{fig:weightsbystatec2} in Appendix D displays the H-SBW weights summed by state alongside BC-HSBW, which extrapolates to reduce the imbalances.

Excluding early expansion states, we estimate an effect of -2.09 (-2.85, -1.33) percentage points using H-SBW weights and -2.05 (-2.75, -1.35) percentage points for SBW. These estimates are quite similar to though slightly closer to zero than the the primary estimates. We also see that the differential between these estimates and the unadjusted estimates is slightly larger: -2.28  (-2.82, -1.74) percentage points for H-SBW and -2.21 (-2.71, -1.72) percentage points for SBW.

When we add the bias-correction the point estimates again move closer to zero: -1.94 (-2.96, -0.92) percentage points for BC-HSBW and -1.99 (-3, -0.99) percentage points for BC-SBW. Overall these results suggests that the results are relatively robust to the exclusion of these states, so that potential violations of this causal assumption do not appear to be a large factor.

\subsection{Covariate importance}

We also investigate our hypothesis that factors associated with Governance are associated with treatment response. As discussed above, we first remove the balance constraints on the Republican governance indicators and estimate $\hat{\psi}^1_v$, and then subtract our original ETC point estimate from this quantity to generate $\hat{\Delta}_v^1$. Because this quantity does not reflect a clear population target, instead of confidence intervals, we present the minimum and maximum leave-one-state-out values in parentheses next to the original estimate.

For the H-SBW estimator we calculate $\hat{\Delta}^1$ equal to -0.69 (min = -0.83, max = -0.42) and equal to -0.79 (min = -0.90, max = -0.66) on our unadjusted dataset. In other words, our primary estimated treatment effect moved 0.78 percentage points further away from zero when we excluded the Republican governance indicators. This reflects a 33 percent decrease in our point estimate, a not-unsubstantial difference. Moreover, all of these estimates were less than zero, regardless of whether we conditioned on the covariate adjustment or not, regardless of whether we remove the early expansion states or not, and when removing each state. Across all specifications that we ran the minimum change we calculated was -1.34 and the maximum was -0.36. Additional distributional results across all leave-one-state-out estimates are available in Appendix E, Table~\ref{tab:rdiffc1}. Figure~\ref{fig:repub} displays our estimates of $\hat{\Delta}_v^1$ on our primary dataset and removing early expansion states (conditional on the covariate adjustment).

We also consider four other covariate sets. We find that our estimates are most sensitive to controlling for pre-treatment outcomes and unemployment rates. This is not unexpected: all else equal, the expansion region had much lower pre-treatment uninsurance rates. If we do not control for these covariates, the comparable region will likely have lower pre-treament uninsurance rates, causing the estimated counterfactual to be closer to zero. The effect estimates were less sensitive to the removal of other covariate groups, and all point estimates are available in Appendix E, Table~\ref{tab:ptests}.

\begin{figure}[H]
\begin{center}
    \caption{Removing Republican Governance Indicators}
    \label{fig:repub}
    \includegraphics[scale=0.6]{01_Plots/repub-diff-all-estimators.png}
\end{center}
\end{figure}

These results highlight the importance of Republican governance in our counterfactual outcome model of $Y^1$. If the models specified by \cite{kaestner2017effects} and \cite{courtemanche2017early} are correct (that is, they correctly omit Republican governance from their balancing weights for estimating $Y^0$), this would suggest treatment effect heterogeneity with respect to Republican governance. Moreover, because the expansion-state region is much more Democratic than the non-expansion region, this heterogeneity could potentially drive differences between the ETC and the ETT.

Since this is a policy question of some interest, we directly investigate this by estimating the outcome model on the full data with treatment assignment interacted with each covariate \footnote{For this analysis we calculate separate covariate adjustments on the untreated data. The summary statistics for this adjustment are available in Appendix D.}. We then examine how the estimated treatment effect would change if we decreased the interaction between treatment assignment and each Republican governance indicator -- Republican governor, Republican lower legislature control, and Republican total control -- by 50 percentage points (note that the original variables are either 0 or 100 and measured at the state level). This linear combination of coefficients estimates how the treatment effect would change for any given collection of states against a set that is identical except for being 50 percentage points lower, on average, across the Republican governance indicators. We find that the linear combination is positive (0.21 percentage points) and statistically significant on the unadjusted dataset. This would indicate that the estimated treatment effect may be larger among Republican governed areas. However, this finding is not robust to any other specification that we run. Ultimately we interpret these results as providing no evidence of treatment effect heterogeneity with respect to Republican governance (though this analysis does not rule out this possibility either). The full results are available in Appendix E, Table~\ref{tab:hte}.


\subsection{Baum-Welch algorithm}


\section{Types}

\subsection{Primary types}
Types are composed of several key expressions:

\begin{grammar}
<type> ::= <name>
      \alt <type application>
      \alt <forall>
      \alt <constraint>
      \alt <type function>
      \alt <type tuple>
      \alt `(' <type> `)'
      \alt `_'
      \alt `[' <type> `]'
      \alt `[|' <type> `|]'
      \alt <record>
      \alt <row>
      \alt <union>
      \alt <unifies>

<var> ::= <ident>
     \alt `(' <ident> : <type> `)'

<type application> ::= <type> <type>
                  \alt <type> <name> <type>
                  \alt <type> \lit{\`{}} <name> \lit{\`{}} <type>

<forall>        ::= `forall' \{ <var> \} `.' <type>

<constraint>    ::= <type> `=>' <type>

<function type> ::= <type> `->' <type>

<tuple type>    ::= <type> \{ `*' <type> \}

<unifies>       ::= <type> \lit{$\sim$} <type>
\end{grammar}
The $type\ application$, $forall$, $constraint$ and $type\ function$ rules are right associative, whilst $unifies$ is non-associative.

\todo[inline]{What is the precedence of these?}

\subsection{Type annotations}
\begin{itemize}
\item \texttt{:} is used to annotate a variable or expression having a type.
\item \texttt{\_} can be used to mark a type wildcard (not a type variable, just something you don’t want to explicitly write). So you could have \texttt{[\_]} to constrain it to be a list of something.
\end{itemize}

\subsubsection{Rows and Unions}
Rows are composed of a series of key-type pairs or a union of two rows:

\begin{grammar}
<row body> ::= \{<ident> `:' <type> `,'\}
          \alt <ident>

<row union> ::= `'
           \alt <row_body> \{ `|' <row_body> \}

<row>      ::= `(' <row union> `)'
\end{grammar}

\todo[inline]{What syntax are we using for union types? Braces are taken for record syntax.}

\subsubsection{Records}
Record definitions are composed of a series of identifier keys to type pairs separated by commas within braces.

\begin{grammar}
<record>      ::= `\{' <row union> `\}'
\end{grammar}

\subsection{Type declarations}
Types can only be declared in a module. There are two forms of type declarations:

\begin{itemize}
\item Aliases: allowing referencing a longer type name as a shorter one (or renaming it if it conflicts or any other reason)
\item Type definitions: used for creating sum and product types.
\end{itemize}

\subsubsection{Type names}
Type names are defined as an identifier followed by a series of free type variables and/or concrete types.
The parameters that are specified within the RHS of the definition \textit{must} exist on the LHS.

\subsubsection{Type aliases}
The \texttt{type} keyword is used to define a type alias:

\begin{grammar}
<type name def> ::= <ident> \{ <var> \}
               \alt `op' (`left' | `right') [<digit>] <var> <ident> <var>
               \alt <var> \lit{\`{}} <ident> \lit{\`{}} <var>

<type name>     ::= <type name>  [ `:' <type> ]

<type def> ::= `type' <type name> `=' <type>
          \alt `type' `foreign' <type name>
\end{grammar}

\subsubsection{Sum type definitions}
Sum types are composed of one or more type-constructors, each followed by the types the product type is composed of.

\begin{grammar}
<product name> ::= <ident> \{<type>\}
              \alt <type> `(' <ident> `)' <type>
              \alt <type> \lit{\`{}} <ident> \lit{\`{}} <type>

<product type> ::= <product name>  [ `:' <type> ]

<sum type>     ::= `data' <type name> `=' \{`|' <product type> \}
              \alt `data' `foreign' <sum name>
\end{grammar}

If the declaration starts on a new line it should have a leading `|', otherwise not.

\begin{minted}{haskell}
data X = A | B

data Y =
    | C Int
    | D
\end{minted}

\paragraph{GADTs}
GADTs are defined as so:

\begin{minted}{haskell}
data Foo a = Foo1 Int : Foo Int
           | Foo2     : Foo a
\end{minted}

Type variables defined on the RHS are accessible on the left:

\begin{minted}{haskell}
data Bar a = Bar1 a b : forall b . Foo a
           | Bar2     : Foo a
\end{minted}

\subsubsection{Type classes}
Type classes are marked with the \texttt{class} keyword. You can then specify a series of constraints on various parameters before specifying the actual type. All constraints’ parameters must appear in the type class’s definition.

\begin{grammar}
<class constraint> ::= <type> `=>'

<functional dep>   ::= \{ <ident> \} `->' \{ <ident> \}

<binding>  ::= <lhs> [`:' <type> ] [`=' <expr>]

<bindings> ::= <binding>
          \alt <binding> \{ `and' <binding> \}

<class body> ::= `type' <type name> [`=' <type> ]
            \alt `data' <type name> [`=' \{ '|' <product type> \} ]
            \alt `let' [`rec'] <bindings>

<class>            ::= `class' \{ <class constraint> \} <type> [ `|' <functional dep> \{ `,` <functional dep> \} ] `where' <class body>

<instance>         ::= `impl' <ident> \{ <var> \} `=' <type> `where' <class body>
\end{grammar}

\begin{minted}{haskell}
class Show a where -- or class Show a =
    let show : a -> String

impl X = Show String where
    let show x = "!" ++ x ++ "!"
\end{minted}

The beginning of the type class’s body is marked with the \texttt{where} keyword and an indent. The body contains a series of variables with type annotations with optional definitions. It is possible for all definitions to be filled and depend on one another: when creating an implementation Amulet will determine if you have provided sufficient information for a complete definition.

\paragraph{Type class implementations}
Implementations share a similar syntax to type class definitions, using \texttt{impl} instead of \texttt{class}. However, instead of following the type class with type parameters you can use any type expression.

The body of the implementation uses an identical syntax to that of type classes, though empty definitions are not allowed.


\section{Standard Module \sectcode{rand}}

\stmodindex{rand} This module implements a pseudo-random number
generator with an interface similar to \code{rand()} in C\@.  It defines
the following functions:

\renewcommand{\indexsubitem}{(in module rand)}
\begin{funcdesc}{rand}{}
Returns an integer random number in the range [0 ... 32768).
\end{funcdesc}

\begin{funcdesc}{choice}{s}
Returns a random element from the sequence (string, tuple or list)
\var{s}.
\end{funcdesc}

\begin{funcdesc}{srand}{seed}
Initializes the random number generator with the given integral seed.
When the module is first imported, the random number is initialized with
the current time.
\end{funcdesc}


\subsection{Analytic continuation}