# Hypothesis test for stratified data without a variance estimate for each strata

I am currently working on a project where I am given an incomplete dataset on the prices of two medical procedures, and I would like to run a hypothesis says that roughly says something like "Procedure A costs more than Procedure B"

My data table looks something like this:

Year | $\text{AvgCost}_{A,t}$ | $\text{AvgCost}_{B,t}$ | $N_{A,t}$ | $N_{B,t}$

1999 | \$300 |$250 | 1000 | 20

2000 | \$325 |$271 | 1020 | 40

2001 | \$500 |$281 | 1050 | 60

where $\text{AvgCost}_{A,t}$ and $\text{AvgCost}_{B,t}$ are the average costs of procedures $A$ and $B$ in year $t$, and $N_{A,t}$ and $N_{B,t}$ are the number of patients who had procedure $A$ and $B$ in year $t$.

The setup is very similar to a stratified random sampling problem with the exception being that I do NOT have a variance estimate for the average cost each year (only the average cost and the sample size).

In light of this, I am wondering if someone can suggest a hypothesis test that I can run on this data?

Right now, the best option I can think of is a 2-sample t-test where we compare the mean values of $\text{AvgCost}_{A,t}$ and $\text{AvgCost}_{B,t}$ year to year. However, this does not take into account for the facts that:

1. The sample size changes each year
2. The costs for both procedures increase year-to-year and are therefore not independent.

First let's deal with your first problem (sample size changes). I will think about the second problem later..

I would probably assume that all the observations of a given procedure have the same distribution, no matter what the year is. So for example for procedure A I would make the assumption that you draw:

$X_A \sim \mathcal{N}(\mu_A, \sigma_A^2)$

This would mean that for year $t$, if I denote by $\bar{X}_{A,t}$ the average across that year and $N_{A,t}$ the measurements you got that year, then (under independence):

$$\bar{X}_{A,t} \sim \mathcal{N}\left(\mu_A, \frac{\sigma_A^2}{N_{A,t}}\right)$$

Now assume that all observations are also independent across years, then you can get an estimate of $\mu_A, \sigma_A$ based on just $\bar{X}_{A,t}, t \in \{t_0\cdots,t_f\}$. For example the maximum likelihood estimates are:

$$\hat{\mu_A} = \frac{\sum_t \bar{X}_{A,t} N_{A,t}}{\sum_t N_{A,t}}$$

and

$$\hat{\sigma_A^2} = \frac{\sum_t (\bar{X}_{A,t}-\hat{\mu_A})^2 N_{A,t}}{\sum_t N_{A,t}}$$

Now calculate the same things also for $X_B$ and then just go ahead and do a Welch t-test using these estimates. I have not thought about what happens to the degrees of freedom though, but if you have enough samples you could just compare to a standard normal.