# Linear regression testing under constraints

Consider the following regression: $$Y_i = \alpha + \beta X_i + \epsilon_i.$$ I have to test the following hypothesis: $$H_0: \alpha = \beta = 0;$$ $$H_1: \alpha \geq 0, \; \beta \geq 0, \quad \alpha \;\text{or}\; \beta \; > 0.$$ In other words, I want to test the null hypothesis that both $$\alpha$$ and $$\beta$$ are equal to $$0$$ against the alternative that both are non-negative and at least one is positive. I understand the logic of the setting, but I do not know how to implement it in practice using F-test or t-test. For example, in Matlab I normally use the function coefTest to test linear regression coefficients, but I cannot figure out how to implement this specific framework.

• Somewhat related: zora.uzh.ch/id/eprint/138641/1/econwp254.pdf Commented Mar 10, 2023 at 12:23
• Here's a paper which extends Wald and likelihood ratio tests to a setting where we have inequality constraints on the parameters. Commented Mar 10, 2023 at 22:44

Do you mean how to implement this in Matlab?

You could always use the Anova function in Matlab to perform F-test.

**sample data

n = 100; X = rand(n,1); Y = 2*X + randn(n,1);

**Estimate the regression coefficients

b = regress(Y, [ones(n,1), X]);

**Compute the F-statistic and p-value

SSR = sum((b(1) + b(2)*X - mean(Y)).^2); SSE = sum((Y - b(1) - b(2)*X).^2); k = 2;

n = length(Y); F = (SSR/(k-1))/(SSE/(n-k)); pval = 1 - fcdf(F, k-1, n-k);

**Print

disp(['F-statistic = ' num2str(F)]) disp(['p-value = ' num2str(pval)])

If the p-value is less than the significance level, you can reject the null hypothesis and conclude that at least one of the coefficients is non-zero.

• What if the coefficients are negative?
– Dave
Commented Mar 10, 2023 at 11:22
• Indeed, I do not think this is an answer to the question Commented Mar 10, 2023 at 12:16