Simple econometric regression

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.

 채택된 답변

Oleg Komarov
Oleg Komarov 2011년 8월 1일

1 개 추천

Use regstats then with the same inputs:
regstats(y,x,'linear')

댓글 수: 3

Marcin Kuc
Marcin Kuc 2011년 8월 1일
Perfect. Thanks a lot. It gives so much information and I was wondering how is it different to:
Betas = [ones(length(X),1) X] \ y
Oleg Komarov
Oleg Komarov 2011년 8월 2일
It uses qr decomposition but it's pretty much the same.
Shashank Prasanna
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
Fangjun Jiang 2011년 8월 1일

0 개 추천

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

Marcin Kuc
Marcin Kuc 2011년 8월 1일
Ok, as for the results that it returns, which ones will be beta0 and beta1? I believe B should be Beta1 and R is an array with residuals. Where's the constant term?
Oleg Komarov
Oleg Komarov 2011년 8월 1일
You have to add a column of ones for the constant. As already suggested read the documentation.
Marcin Kuc
Marcin Kuc 2011년 8월 1일
I tried to understand it, but it appears to be far too complicated for typical Eviews users. I will definitely dive into it after I finish my current project.
However, I would be very grateful if you could tell me exact way of getting the constant. Thank you in advance.

댓글을 달려면 로그인하십시오.

Fangjun Jiang
Fangjun Jiang 2011년 8월 2일

0 개 추천

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

카테고리

도움말 센터File Exchange에서 Econometrics Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by