Why do i get tstat Inf after a linear regression?

4 Ansichten (letzte 30 Tage)
Jefferson Sola de Haro
Jefferson Sola de Haro am 6 Nov. 2020
Beantwortet: the cyclist am 6 Nov. 2020
Hellow folks,
I saw that the comunity is very active so i hope someone can help me. I am writing down a simple function to estimate and evaluate the beta values for a regression, as well as its respective ANOVA.
If i run my Constraints and Effects algorithm it all works fine, but once i do a simple regression using fitlm(), i cannot evaluate the ANOVA, here is my code and what i get:
Y = [33.2 31.2
4.6 9.6
40.6 39.4
162.4 158.6];
X = [-1 -1
1 -1
-1 1
1 1 ];
Y_mean = mean(Y,2) ;
mdl = fitlm(X,Y_mean,"interactions")
mdl = Linear regression model:
y ~ 1 + x1*x2
Estimated Coefficients:
Estimate SE tStat pValue
________ __ _____ ______
(Intercept) 59.95 0 Inf NaN
x1 23.85 0 Inf NaN
x2 40.3 0 Inf NaN
x1:x2 36.4 0 Inf NaN
Number of observations: 4, Error degrees of freedom: 0
R-squared: 1, Adjusted R-Squared: NaN
F-statistic vs. constant model: NaN, p-value = NaN
With such result, of course once i call anova(mdl) the answer will be bad.
What could be the root cause?

Antworten (1)

the cyclist
the cyclist am 6 Nov. 2020
The root cause is that your model is "perfect". The model is effectively
y = b1 + b2*x1 + b3*x2 + b4*x1*x2
which means you have 4 free parameters to fit 4 equations.
The estimated coefficients will perfectly fit this sample of (X, Y_mean) data. In this case, the t-statistic is infinite. Off the top of my head, I think the p-values probably is (or "approaches") 0 in this case, but again it is not very meaningful for a perfect fit.

Kategorien

Mehr zu Analysis of Variance and Covariance finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by