フィルターのクリア

Linear regression comparable to excel

48 ビュー (過去 30 日間)
David Polcari
David Polcari 2013 年 7 月 30 日
Hi, I am trying to create a function similar to the LINEST function in excel, which does linear regression. The excel function outputs the following parameters:
  • m: slope
  • Sm: standard deviation of the slope
  • b: intercept
  • Sb: standard deviation of the intercept
  • Sy: standard deviation about regression
  • R^2: coefficient of determination
  • SSreg: The regression sum of squares
  • SSres: The residual sum of squares
I am aware that I can use polyfit to obtain m and b but I am not sure how to obtain the other without manually inputting formulas. Can anyone help?
I am using a simple set of test data:
  • x = [1 2 3 4 5]
  • y = [5 15 25 30 35]
Excel gives me the following result: * m: 7.5 * Sm: 0.76 * b: -0.5 * Sb: 2.5 * Sy: 2.4 * R^2: 0.97 * SSreg: 562.5 * SSres: 17.5
I don't expect to get the EXACT same result but something close. Thanks.

回答 (2 件)

dpb
dpb 2013 年 7 月 30 日
If you have Statistics Toolbox there's regstats that's close (missing SS terms) or the LinearModel that has all of 'em. That notwithstanding it's code 'em up yourself or see if there's something on the FEX that has done so already.

Shashank Prasanna
Shashank Prasanna 2013 年 7 月 30 日
You can get all those results when you use the LinearModel functionality in the Statistics Toolbox:

カテゴリ

Help Center および File ExchangeSupport Vector Machine Regression についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by