MATLAB: Estimate and SE in a linear regression becomes 0

dummylinear regressionstandard errorsStatistics and Machine Learning Toolbox

…and tStat and pValue becomes NaN. What is the typical reason for that? It is a dummy (either 0 or 1) by the way.
I get the error message below after fitting the linear model (first line):
mdl = LinearModel.fit(ds,'linear','RobustOpts','on');
Warning: Regression design matrix is rank
deficient to within machine precision.
> In TermsRegression>TermsRegression.checkDesignRank at 98
In LinearModel.LinearModel>LinearModel.fit at 969
What is the typical reason for that?
It is a dummy (either 0 or 1) by the way.

Best Answer

It means exactly what the error message is saying. Your data is rank deficient.
As a caution, when you use datasets as the input to your LinearModel.fit function it assumes that the very last column is the response variable 'y'. If this assumption is untrue in your case you will have to change it by specifying it explicitly using 'ResponseVar'.
Here is an example that yields the same error message you are getting and you can see from the data how it is bad:
mdl = LinearModel.fit(repmat(randn(1,4),10,1),ones(10,1),'linear','RobustOpts','on');