# Multiple Regression and Statistical Significance

I have a two-part data set comprised of treated and untreated values. When plotted on an X,Y axis, one expects the data two fall into two distinct lines with no expectation that either the slopes or the intercepts will be the same.

I am modeling this with a categorical/indicator value as follows, in order to capture the idea of non-parallel lines (I is the indicator variable):

Y = a0 + (a1-a0)*I + b0X + (b1 - b0)XI

Using Matlab's fitlm command, this is:

mdl = fitlm(T, 'Y ~ X * I')

where T is the table of data, we ask for a regression of Y expressed in XI, and the fitlm command then forces additional terms for I and X alone.

I have tested this in Matlab, and it gives me what I want in terms of coefficients-- I can make scatter plots of fake data, plot the two regression curves (one for each value of the indicator), see that they match the data, the coefficients seem to have the interpretations I desire, etc.

What I would like to be able to do is to run a test (a t-test, I think?) of the two slopes vs each other, and the two intercepts vs each other. I.e., I would like to be to state that the slopes, say, are different values up to some significance, say, p < 0.05.

How does one do such a thing?

Example code for the fake data, model, and plot follows:

X = [0:.01:10, 0:.01:10]';

Y(1:1001) = X(1:1001) + randn(1,1001)' * .1 ;
Y(1002:2002) = 1 + 0.5* X(1002:2002) + randn(1,1001)' *.1 ;
Y = Y';

I(1:1001) = ones(1,1001);
I(1002:2002) = zeros(1,1001);
I = I';

T = table(X, Y);
T.I = nominal(I);

mdl = fitlm(T, 'Y ~ X * I')

x = [0:.01:10];
y0 = mdl.Coefficients{1,1} + mdl.Coefficients{2,1}*x + mdl.Coefficients{3,1} + mdl.Coefficients{4,1}*x;
y1 = mdl.Coefficients{1,1} + mdl.Coefficients{2,1}*x;

scatter(X,Y);
hold on;
plot(x, y0, 'g');
plot(x,y1, 'r');


The coefficient of $XI$ is the estimate of the difference in slopes. The t-statistic for that coefficient (which you should be able to get in the usual regression table for the coefficients in the model) allows you to test for the difference.
Similarly the coefficient of $I$ is the estimate of the difference in intercepts, and the same comments apply. (However interpretation of that coefficient if the slopes are unequal may be difficult, since it relates only to the difference in mean when $X = 0$)