the use of Regress

2 ビュー (過去 30 日間)
chengxuan yu
chengxuan yu 2013 年 6 月 28 日
Thanks in advance, any comments will be appreciate! [B,BINT,R,RINT,STATS] = regress(Y,X) Did the vector X 'must' contain an ones vector? And if it includes,what the dimension is it ?

回答 (1 件)

Wayne King
Wayne King 2013 年 6 月 28 日
編集済み: Wayne King 2013 年 6 月 28 日
Yes, you should include a vector of ones. The vectors of ones represents the constant term in the linear regression. In other words, it's the \beta_0 term below. The dimension is simply Nx1 where N is the number of observations.
Y = \beta_0+\beta_1*X+\beta_2*X+....
The F-statistic assumes there is a constant term in the model.
For example:
load carsmall
% fit a first order linear model of Weight as a function of Horsepower
X = ones(length(Weight),2);
X(:,2) = Horsepower;
Y = Weight;
[b,bint,r,rint,stats] = regress(Y,X);
plot(Horsepower,Weight,'*');
xval = min(Horsepower):0.01:max(Horsepower);
yhat = b(1)+b(2)*xval;
hold on;
plot(xval,yhat,'r')

カテゴリ

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