# 1-sided two sample t-test with covariate adjustment

I have a biological problem which involves using a 1-sided two-sample t-test. To simplify the problem, let’s assume an experiment comparing quantities in a control (C) and a treatment (T) group, each having 3 replicates, called C1, C2, C3, T1, T2, T3. Here, C1 and T1 are samples from the same subject, C2 and T2 are samples from the same subject, and so on.

Now I obtain a number for each of the following combinations. "within" = within group (i.e. both are C or both are T). Also, the number after C or T indicate whether they're from the same subject (sub) or not.

C1_C2 (within: different sub)
C1_C3 (within: different sub)
C1_T1 (between: same sub)
C1_T2 (between: different sub)
C1_T3 (between: different sub)
C2_C3 (within: different sub)
C2_T1 (between: different sub)
C2_T2 (between: same sub)
C2_T3 (between: different sub)
… (a total of 15 pairwise quantities)


We are essentially interested in comparing the quantities "within" group and the quantities "between" group, but hoping to incorporating the "subject" effect somehow in the t-test. Is there a way to distinguish “different sub” and “same sub” in the test?

Thank you so much for your suggestions!!

You can try and use linear regression using dummy variables. Try to regress the difference of each pair (let's call it $Y_i$) with a dummy variable marking if it's a "between" group ($D_1$ which can get 1 if it's "between" or 0 if it's "within") and an interaction dummy variable $D_1\cdot D_2$ ($D_2$ gets 1 if it's "same sub" of 0 otherwise).

So the regression equation will be:
$Y_i=\beta_0+\beta_1\cdot D_{1,i} + \beta_2\cdot D_{1,i}\cdot D_{2,i} + \epsilon_i$
where:
$Y_i$ - each pairwise difference
$D_{1,i}$ - 1 if it's "between", 0 otherwise
$D_{2,i}$ - 1 if it's "same sub", 0 otherwise

The results can be interpreted:
$\beta_0$ - the mean difference in the "within" group
$\beta_0 + \beta_1$ - the mean difference in the "between" group, without "same sub"
$\beta_0 + \beta_1+ \beta_2$ - the mean difference in the "between" group, with "same sub"

If you run this regression in stata, for example, you will get the t-test result for each $\beta$, so you could know if it's statistically significant. If $\beta_1$ is significant, it means that the change between the groups is significant. If $\beta_2$ is significant, it means that the "same sub"/"different sub" distinction is significant.