Assume that I am interested in performing a between group comparison for a given variable but I know that this $y$ variable is confounded by at least a couple of other variables.
Say, $y = Device_1 + Device_2 + Confound_1 + Confound_2$ where $y$ denotes the variable of interest, $Device_1$ indicates measurements made using one device (coded as 0/1), $Device_2$ indicates measurements made using second device (coded as 0/1), and $confound_1$ and $confound_2$ indicate two continuous variable which are confounding my measurements.
Therefore, I can fit a linear regression model with $Device_2$ as a 0/1 encoded variable along with $confound_1$, $confound_2$ , and the $intercept$. Then, the $intercept$ would model the mean of $Device_2$ and the slope associated with $Device_1$ would be the difference between the means of devices. I can then read off the $T$ statistics of $Device_2$ and associated $p$ value. Alternatively, I can model both $Device_1$ and $Device_2$ without the $intercept$ (the slopes would then represent the means of each devices) and then perform a coefficient testing with the contrast $c = [1 -1]$ to get my $T$ and $p$ value (for example, using coefTest
in MATLAB and then converting the $F$ value to $T$ value).
However, in case where I have multiple categorical variables, how can I do a coefficient testing to test if the two devices statistically differ? Specifically, say if I extend the model as $y = Device_1 + Device_2 + Confound_1 + Confound_2 + Sex$ where $Sex$ is coded as 0/1 for female subjects. Specifically, if I model the intercept, then the slopes would be the difference of means from the combined (additive) effect of male subjects and the $device=0$ and thus the coefficient test would not indicate the difference between the devices...right?
Bonus question: if $device$ had multiple levels and I wanted to do an ANOVA, would anything change in terms of the model itself (I can change the contrast vector to account for an ANOVA)?
Related questions: