Returning the p values of a system estimation

For questions regarding programming in the EViews programming language.

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

309blank
Posts: 9
Joined: Mon Jan 04, 2016 6:48 am

Returning the p values of a system estimation

Postby 309blank » Wed Aug 03, 2016 7:07 am

I have a large number of different system estimations that I want to compare.

In order to do that I wanted to create an efficient Table so that I can compare these systems that have different specifications and estimate similar but sometimes slightly different parameters. In order to do that and facilitate the export to LateX I wanted to export a CSV from eviews.

I am not that familiar with eviews programming which is why the first thing I tried was this inelegant solution:

Code: Select all

output(s) testspool 'send output to a spool called testspool %system_list_3f = @wlookup("ces_3f*","system") 'store names of systems in a vector for %sys {%system_list_3f} testspool.append %sys next
This sorta works, but the default output left a lot to be desired and the work of importing and sorting it into excel (for 38 systems) is just inefficient.

I now looked into calling the necessary values directly and building a table from scratch, which seems like a good way to go about it. One problem however, is that I can't extract @pvals from the systems like i can with @coefs and @stderrs. What are your recommendations as to how I go about that? I'm running Eviews 8.

Edit: I'd also like to extract the names of the coefficients. I seem to not be able to do that unfortunately, @coeflist from the equation object does not work here. Does anybody know a workaround?

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

Re: Returning the p values of a system estimation

Postby EViews Gareth » Wed Aug 03, 2016 3:47 pm

You'll have to calculate the p-values manually from the tstats (@tstats) using the appropriate distribution function.



There is no way to retrieve the coefficient labels.


In general for this project, you might want to download the eqtabs add-in and look at the source code. It does something very similar to what you want, but with equations rather than systems. Much of the logic in the add-in could be applied to your case.

309blank
Posts: 9
Joined: Mon Jan 04, 2016 6:48 am

Re: Returning the p values of a system estimation

Postby 309blank » Thu Aug 04, 2016 4:46 am

Thank you, I found that the Add-In just uses @tdist, which is very useful to know.

One of the drawbacks of being unfamiliar with a program is always that you miss really simple tricks to do it. For anybody wondering, here is a code snippet that could be used:

Code: Select all

!df = ({%sys}.@regobs-{%sys}.@ncoefs) !tstat = {%sys}.@tstats(!i) ' get tstat for coef i !pval = @tdist(!tstat,!df)
I'm going with a different tack now, since in all my models the first coefficient is named "PSI(1)" I can extract the values of the coefficients from the frozen results table using the following code:

Code: Select all

!row = 1 'control to write in the right row !col = 1 'control to write in the right column for %sys {%system_list_3f} !row = 1 'reset the row to 1 for every system freeze(temp_results, mode=overwrite) {%sys} 'save the results as a table all_results(!row, !col) = {%sys}.@name 'Title of system !row = !row + 1 'Block writing the coefficients and their statistics 'Find the start in the table temp_results !findit = 8 'we know the start is below here somewhere while (temp_results(!findit,1) <> "PSI(1)") and !findit < 25 'end the search if something goes wrong !findit = !findit +1 wend for !x=1 to ({%sys}.@ncoefs) 'loop over the coefficients of the system all_results(!row, !col) = temp_results(!findit+!x+2,1) 'first the name of the coefficient, I have no idea why I had to increment the found value by another 2, but so be it. all_results(!row, !col +1) = temp_results(!findit+!x+2,2)'the value of the coefficient 'optional: include test here of p-value and assign stars to string for later latex export! !row = !row+ 1 all_results(!row, !col) = "Std. Error" 'The standard error all_results(!row, !col +1) = temp_results(!findit+!x+2,3)'the value of the standard error !row = !row+ 1 all_results(!row, !col) = "t-statistic" 't-statistic all_results(!row, !col +1) = temp_results(!findit+!x+2,4)'the value of the t-statistic !row = !row+ 1 all_results(!row, !col) = "P-value" 'P-value all_results(!row, !col +1) = temp_results(!findit+!x+2,5)'the value of the p-value !row = !row+ 1 next 'End block of writing coefficients !col = !col +2 'End the writing for the system by incrementing the columns by 2 next

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

Re: Returning the p values of a system estimation

Postby EViews Gareth » Thu Aug 04, 2016 5:28 am

Good stuff.

Note that @tdist only works if your statistics follow the student-t distribution (obviously!).


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests