Access Standardized Residuals and Count

For questions regarding programming in the EViews programming language.

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

diggetybo
Posts: 152
Joined: Mon Jun 23, 2014 12:04 am

Access Standardized Residuals and Count

Postby diggetybo » Tue Feb 21, 2017 4:58 am

Given a equation object eq_01, I want to create a 1 line code that counts a property of the equation object that can be run from the command line.

Specifically I'm trying to write a scalar comprehension: the percentage representation of how many standardized residuals have an absolute value greater than 2

Currently I'm using the following to access the standardized residuals:

eq_01.makeresid(s) res_std

I have two questions:

1. Is there any way to access the standardized residuals using the existing eq_01 object only? In other words not needing to create a new res_std object?

2. Is there a way to do a count if type of operation from the command line? I only know of @recode() which, if I'm not mistaken also would output an additional series object of 1's and 0's.

For clarity let me provide my pseudo code:

Code: Select all

scalar my_scalar = percentage of standardized residuals of eq_01 having @abs() greater than or equal to 2.
It's rather simple, but the only solutions I have seen so far is using an actual program. I'm apprehensive about having to write, save, and then at a later time load a program, every time I need perform a simple calculation.

EViews Matt
EViews Developer
Posts: 584
Joined: Thu Apr 25, 2013 7:48 pm

Re: Access Standardized Residuals and Count

Postby EViews Matt » Tue Feb 21, 2017 3:51 pm

Hello,

Unfortunately, I don't think what you're asking for is possible as a one-liner.
  1. The "makeresids" procedure is the only way to access the residuals, there is no data member for that information that I'm aware of. Keep in mind that immediately after estimating the equation the residuals will have been automatically stored in the "resid" series of the appropriate workfile page, which grants you at least temporary access to the residuals.
  2. With the residuals already in a series, e.g., "resid", here are some options for calculating the percentage you want. All of these assume the current sample is the entire workfile range.

    Code: Select all

    scalar my_scalar = 100 * @sum(@ege(@abs(@convert(@nan(resid, 0))), 2 * @ones(@obsrange))) / @obsrange

    Code: Select all

    smpl if @abs(resid) >= 2 scalar my_scalar = 100 * @obssmpl / @obsrange

    Code: Select all

    series dummy = @abs(resid) >= 2 scalar my_scalar = 100 * @sum(dummy) / @obsrange
Last edited by EViews Matt on Wed Feb 22, 2017 10:00 am, edited 1 time in total.

diggetybo
Posts: 152
Joined: Mon Jun 23, 2014 12:04 am

Re: Access Standardized Residuals and Count

Postby diggetybo » Tue Feb 21, 2017 8:29 pm

That is a very impressive @sum(), I would have never thought of that. I'm very happy with that solution, I don't need an actual eviews program file since it all works from the command line. Thank you for helping me understand how eviews works these situations out.

EViews Matt
EViews Developer
Posts: 584
Joined: Thu Apr 25, 2013 7:48 pm

Re: Access Standardized Residuals and Count

Postby EViews Matt » Wed Feb 22, 2017 9:59 am

It's verbose, but it does work. If your residuals will never contain NAs then you can remove the use of @nan, it's there only to ensure that @convert returns a correctly sized vector in the presence of NAs. And I now realize you wanted absolute values greater than or equal to two, I'll make appropriate edits to my post above.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 1 guest