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.


1 Answer 1


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);


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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.