Simple econometric regression
14 次查看(过去 30 天)
显示 更早的评论
Hi,
I would like to perform a simple econometric regression using Matlab, but I have been struggling to do it for a few days now. Quite simply, I have a set of data for both X and Y. I would like to perform a regression of the following form: Y= BetaZero + Beta*X + ErrorTerm. Could anyone please tell me what is the right function to do so? I've been trying to accomplish that by using regress(), but I realised that it does not return the value of the constant term (aka Beta zero or alpha). Thank you very much for your help.
0 个评论
采纳的回答
Oleg Komarov
2011-8-1
Use regstats then with the same inputs:
regstats(y,x,'linear')
3 个评论
Shashank Prasanna
2013-1-12
If you open up regstats or regress in MATLAB using the edit command you will see that it does the same as what you describe with \ operator. An alternative and recommended approach is the new LinearModel.fit(X,y) which will give you the result and the fit statistics. Make sure you are using MATLAB R2012a and above
更多回答(2 个)
Fangjun Jiang
2011-8-1
You have the right function. Just try it with three return variables.
[B,BINT,R] = REGRESS(Y,X) returns a vector R of residuals.
Read the full text of help regress
3 个评论
Oleg Komarov
2011-8-1
You have to add a column of ones for the constant. As already suggested read the documentation.
Fangjun Jiang
2011-8-2
To use regress();
x=(1:100)';
y=10+2*x+rand(100,1);
[B,BINT,ErrorTerm]=regress(y,[ones(size(x)),x]);
BetaZero=B(1)
Beta=B(2)
BetaZero =
10.6381
Beta =
1.9976
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Econometrics Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!