Command Reference : User Objects : Examples
Simple Container Object (ResStore)
Rolling Regression Estimation Object (Roll)
To illustrate the use of registered user objects, we examine two of the EViews user objects that are currently available for download from our website. (To follow along with these examples, we recommend that you first download and install the corresponding user object using the steps outlined in “Downloading a Registered User Object”.)
The first example uses a simple container user object (of type ResStore) that allows you to add, extract, and display graphs, tables and estimation objects. The second example performs rolling regression estimation using the Roll user object.
Simple Container Object (ResStore)
This first example uses the ResStore user object to create a storage container for objects from our workfile. This is a bare bones registered object that nonetheless shows the basic features of registered user objects.
We use the workfile “Demo.WF1” (which may be found in the example files subdirectory of your EViews installation directory) and assume that you have already installed the ResStore object class.
You may create a new ResStore object by clicking on Object/New Object... and then selecting resstore in the list of object types.
Notice that while the built-in EViews objects are listed alphabetically, the two user objects (ResStore and Roll) are simply placed at the bottom of the listbox. Select resstore and specify the name STOREDOBJECT for our new object. Click on OK to create the object. Alternately, enter the command
resstore storedobject
in the EViews command line and hit ENTER.
As part of its construction, the ResStore object will display a dialog asking you to enter the names of the workfile objects you would like to store:
You may enter the names of any matrix objects (including scalars), strings objects, estimation objects, or view objects (graphs, tables, spools).
Note that there is a check-box that lets you specify whether to remove the objects from the workfile after storing them. You should selection this option if you wish to move, rather than copy, the specified objects into the ResStore.
Once you hit OK, a new ResStore object named STOREDOBJECT will be added to your workfile. If you open up the ResStore object, a spool view display of all objects currently stored is shown:
You may use the View menu to access the defined views for this type of object which allow you to show various subset types of the objects in the container:
Similarly, the Proc menu lists procs which allow you to add, remove, and extract objects from the storage container:
As with other EViews objects, you may use the command language to work with the ResStore object. For example the defined view command,
displays all of the graph objects in the object
extracts all of the objects from STOREDOBJECT into the workfile.
The command
string storednames = storedobject.@members
saves a list of the stored object names in the string object STOREDNAMES.
Rolling Regression Estimation Object (Roll)
Our second example uses the Roll user object to estimate rolling regressions. We again use the workfile “Demo.WF1”, and we assume that you have already installed the Roll object class.
You can create a new Roll object by clicking on Object/New Object... and then selecting roll in the list of object types, or by entering the roll command followed by the name of a new object in the command line:
roll myroll
As part of its creation, the Roll object will display a series of dialogs prompting you to provide information on how the object should be constructed. First, you will be asked whether to create the new object using the specification from an existing equation or by specifying an equation manually:
Since we will use one of the previously estimated equations in our workfile as the basis of our rolling regression, click on OK to accept the default.
Next, you will be asked to select your base equation and to specify the basic type of rolling regressions you wish to perform:
To obtain recursive estimates based on equation EQ01 choose EQ01 in the drop-down menu and select Anchored at start. Click on OK to continue.
Lastly, you will be prompted to provide sample information and a step size:
Click on OK to create the Roll object using the specified settings.
(Note that if you had chosen Manual equation specification in the first dialog or Fixed window estimation in the second dialog, the subsequent dialogs would provide a different set of options).
EViews estimates the rolling regression and, like built-in estimation objects, displays basic estimation information in the object window:
These basic results may be viewed at any time by selecting View/Summary in the object view menu or by entering the object command
in the command line.
Next, consider the custom views that have been defined for this object. In addition to the summary view, you may display information on the coefficient statistics, residual statistics, likelihood statistics, members of the object, and the standard label information view for the Roll object:
Clicking on View/View rolling coefficient statistics... display a dialog prompting you to select the coefficients and statistics you wish to display. By default, the object will display the coefficient estimates for all of the coefficients in the regression:
Click on OK to accept the default values and to display a graph of the results in the object window:
Equivalently, you could have issued the command:
myroll.rollcoefs c log(gdp) rs dlog(pr)
in the command line.
Note that you could have specified a different statistic in the dialog or add the “stat=” option to the command to display a different coefficient statistic. For example, selecting P-values in the dialog or entering,
myroll.rollcoefs(stat=pvals) c log(gdp) rs dlog(pr)
displays the coefficient t-statistic p-values:
Similarly, you may click on the Proc menu to display a list of the user defined procs:
The first two entries re-initialize the Roll object using the dialogs we first encountered when creating MYROLL. The next three menu entries extract results into the workfile. For example, clicking on Extract rolling residual statistics... opens a dialog prompting you to identify the results you wish to extract along with the destination:
Clicking on OK t saves the statistics in the workfile in the series ROLL_R2. The command
myroll.extractresidstat(stat=r2s) roll_r2
performs an equivalent operation.
It is worth noting that behind-the-scenes in this object is a set of user programs that use standard EViews programming tools to display dialogs, perform computations, and display and extract results.