MATLAB Answers

I seem to be getting quite different results when I use regress vs fitlm to do multivariate regression. Why?

5 views (last 30 days)
Rajesh Rajaram
Rajesh Rajaram on 5 Apr 2016
Edited: Walter Roberson on 6 Apr 2016
I am looking for a function suggestion for the best suited for this functionality
  2 Comments
Rajesh Rajaram
Rajesh Rajaram on 5 Apr 2016
I have a signal that I am thinking is a sum of 3 sine waves. The data is both not uniformly spaced and severely undersampled. So I can't use a DFT. Hence I used the following:
Signal = Signal - mean(Signal)
Coef_regress = regress(Signal',[SinWave1; CosWave1; SinWave2; CosWave2; SinWave3; CosWave3]')
Coef_fitlm = fitlm([SinWave1; CosWave1; SinWave2; CosWave2; SinWave3; CosWave3]',Signal')
Coef_regress_ones = regress(Signal',[ones(size(SinWave1)); SinWave1; CosWave1; SinWave2; CosWave2; SinWave3; CosWave3]')
The Coef_regress_ones matches with fitlm output, but with a large intercept value. But I already removed the mean value. I don't understand why.

Sign in to comment.

Answers (1)

Star Strider
Star Strider on 5 Apr 2016
‘The Coef_regress_ones matches with fitlm output, but with a large intercept value. But I already removed the mean value. I don't understand why.’
We still don’t have your data.
Removing the mean would not remove a trend (linearly-increasing baseline).
  2 Comments
Star Strider
Star Strider on 6 Apr 2016
My pleasure.
Removing the mean does not necessarily mean that your signal does not have some sort of linear baseline trend.
Adding the ones vector allows the intercept to be estimated uniquely rather than being forced through zero. If you do not specify a ones column, the model forces a zero intercept.

Sign in to comment.

Tags

Products

Community Treasure Hunt

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

Start Hunting!