how to make a program to produce a OLS coeffients by using matrix calculation?

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Jason, EViews Moderator, EViews Matt

ecofine
Posts: 28
Joined: Fri Sep 26, 2014 2:24 am

how to make a program to produce a OLS coeffients by using matrix calculation?

Postby ecofine » Tue Apr 24, 2018 4:13 am

Dear Folks,

I've been trying to make a simple program to run a matrix form of OLS by using eviews.
My problem is so simple but can't find answer by myself.
That is,

let's suppose there are a simple equation as below;

y = c + b*x + u

so, I have a data of x (small x - independent variable) now and trying to estimate the coefficient of b by OLS.

Then, we know that b = @inverse(@transpose(X)*X)*X'Y; here large X is a matrix of having the column vector of ones and independent variable x (small x).

But I do not know how to make this large X matrix by using eviews command.

Could you help me to solve this problem?

Thank you very much!

HIS

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13294
Joined: Tue Sep 16, 2008 5:38 pm

Re: how to make a program to produce a OLS coeffients by using matrix calculation?

Postby EViews Gareth » Tue Apr 24, 2018 7:23 am

Put the X variables (including "c" for the constant) in to a group, then use the stom command to convert that group into a matrix.
Follow us on Twitter @IHSEViews

ecofine
Posts: 28
Joined: Fri Sep 26, 2014 2:24 am

Re: how to make a program to produce a OLS coeffients by using matrix calculation?

Postby ecofine » Tue Apr 24, 2018 11:24 pm

Thank you very much for your kind answer!

I did following program as you mentioned and it worked nicely.
series x0=log(sandp)
group x1 c x0
stom(x1, x2)
vector y = log(ford)
vector b = @inverse(@transpose(x2)*x2)*@transpose(x2)*y
show b
series y1=log(ford)
ls y1 c x0

By the way, I still have more questions if you would be ok;
that is, can i use only matrix command of eviews and just make the new matrix including c and x data not using group?
Could you kindly help me out this problem?

Gracias!

HIS


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 15 guests