Hello!
Is it possible to do a least square regression with matrices in eviews? I tried as below with yieldstat and loptidsak being matrices but did not get it to work. What is the best way to do?
equation eq1.ls yieldstat c loptidsak
Best regards
least square regression matrices
Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13604
- Joined: Tue Sep 16, 2008 5:38 pm
Re: least square regression matrices
You cannot.
Either convert the matrices to series/groups (mtos function), or calculate the coefficients manually using matrix algebra.
Either convert the matrices to series/groups (mtos function), or calculate the coefficients manually using matrix algebra.
-
CharlieEVIEWS
- Posts: 202
- Joined: Tue Jul 17, 2012 9:47 am
Re: least square regression matrices
A third, more tedious option would be to xput <matrix> into matlab/R and xrun an ols.m (from the lesage toolbox or otherwise). However, this requires you have a valid matlab license if opening a matlab connection, and then you still would have to bring the objects you wanted back into eviews.
-
sakerstallda
- Posts: 7
- Joined: Thu Aug 27, 2015 5:17 am
Re: least square regression matrices
Thank you.
I have realised that everything I want to do would be easier in Matlab, but unfortunately I do not have a license.
Actually, what I want to do is to perform a simple regression with two vectors (not matrices) and to save the slope coeffecient and intercept in another vector. Can I use "ls" for vectors, or it has to be series? How do I convert vectors back to series? How do I save the slope and intercept in a vector?
I would really appreciate your help!
Best regards
I have realised that everything I want to do would be easier in Matlab, but unfortunately I do not have a license.
Actually, what I want to do is to perform a simple regression with two vectors (not matrices) and to save the slope coeffecient and intercept in another vector. Can I use "ls" for vectors, or it has to be series? How do I convert vectors back to series? How do I save the slope and intercept in a vector?
I would really appreciate your help!
Best regards
Re: least square regression matrices
I think you can use the Optimize feature in EViews:
Estimated parameters and their standard errors are stored in vector coefvec and stdvec, respectively.
Code: Select all
'Generate some artificial data
wfcreate u 100
series x1 = nrnd
series x2 = nrnd
series y = 5 + 3*x1 + 2*x2 + nrnd/2
group xgr.add 1 x1 x2
stom(xgr,xmat)
stom(y,yvec)
'OLS analysis with matrices
vector(3) coefvec = 1
vector(100) resvec
scalar minsq
optimize(min=1,finalh=hessmat) olsmat(resvec,coefvec, yvec, xmat)
scalar sig = @sqrt(@sum(resvec)/(@obs(resvec)-@rows(coefvec)))
vector stdvec = @sqrt(@getmaindiagonal(2*sig^2*@inverse(hessmat)))
subroutine olsmat(vector res,vector betas,vector yvar,matrix xvar)
res = yvar-xvar*betas
res = @epow(res,2)
endsubWho is online
Users browsing this forum: No registered users and 1 guest
