Hello,
I am trying to estimate a NARDL model within an Eviews model object equation and have been having difficulty generating an equation in Eviews that first produces the cumulative sum. To be clear, the model solves fine the way it is, but I would like to change one of the equations to a NARDL and therefore need to first construct a cumulative sum variable.
This is quite easy to do with a series, but of course, the series does not update nor does it run in the model projection period. It appears as if the model object does not recognise @sum or @cumsum, as when I open my model object, usually most equations have F(x,y) whereas when I use @cumsum there is simply nothing. I am wondering if I am missing something completely?
I first tried {modelname}.append y_plus = @cumsum(dlog_y_plus) but this does not seem to be appending itself properly to the model. In the periods prior to the estimation, the values are equal to the series I have also estimated (which is fine), but in the periods afterthe start of the estimation, the y_plus variable is simply the last value in the series.
It would be great to get some advice on which functions work within the Eviews model equation object that I might be able to use for such a task.
Thank you
Programming a cumulative sum function that works in a model object
Moderators: EViews Gareth, EViews Jason, EViews Moderator, EViews Matt

 EViews Developer
 Posts: 476
 Joined: Thu Apr 25, 2013 7:48 pm
Re: Programming a cumulative sum function that works in a model object
Hello,
You're quite right, functions such as @sum and @cumsum do not operate on endogenous variables as you'd expect. Basically, the value of those functions is calculated only once at the beginning of a solve operation, ignoring any subsequent changes made to the endogenous variables over the course of the optimization. This causes those functions to be treated as constants, which can also affect how equations are displayed in the model view. Functions that depends on an entire series or a variable number of observations all have this limitation, which includes the summary statistic functions and the cumulative functions.
You're quite right, functions such as @sum and @cumsum do not operate on endogenous variables as you'd expect. Basically, the value of those functions is calculated only once at the beginning of a solve operation, ignoring any subsequent changes made to the endogenous variables over the course of the optimization. This causes those functions to be treated as constants, which can also affect how equations are displayed in the model view. Functions that depends on an entire series or a variable number of observations all have this limitation, which includes the summary statistic functions and the cumulative functions.
Re: Programming a cumulative sum function that works in a model object
Thank you for the reply and confirmation.
Is there any alternative or way to manipulate things such that I would be able to calculate a sum at each of the points the model solves?
Or is it impossible to have anything in an equation that relies on a changing / expanding window and therefore impossible to run a NARDL?
Thanks
Is there any alternative or way to manipulate things such that I would be able to calculate a sum at each of the points the model solves?
Or is it impossible to have anything in an equation that relies on a changing / expanding window and therefore impossible to run a NARDL?
Thanks

 EViews Developer
 Posts: 476
 Joined: Thu Apr 25, 2013 7:48 pm
Re: Programming a cumulative sum function that works in a model object
After thinking about this issue for a while, I believe there's a tolerable workaround so long as your model doesn't contain any leads and your solution sample is contiguous (no gaps). Try specifying your cumulative sum series as:
Code: Select all
{modelname}.append y_plus = @nan(y_plus(1), @cumsum(dlog_y_plus(1))) + dlog_y_plus
Re: Programming a cumulative sum function that works in a model object
Hello Matt,
Thanks for this suggestion. I had also been fiddling with things since my last post and came to a very similar solution.
I didn't have the @nan or @cumsum within the equation, but in the series definition prior to the equation, so that the model equation simply updated the cumulative sum from the previous series value. I was a little worried that the model equation object would not accept any Eviews commands.
(sample to stop when estimation starts)
series dlog_y = @nan(d(log(y)),0)
series pos_dlog_y = @pmax(dlog_y,0)
series sum_pos_dlog_y=@cumsum(pos_dlog_y)
(all sample)
{modelname}.append sum_pos_dlog_y = sum_pos_dlog_y(1)+pos_dlog_y
Your solution seems a little more elegant
Thank you for your help.
Thanks for this suggestion. I had also been fiddling with things since my last post and came to a very similar solution.
I didn't have the @nan or @cumsum within the equation, but in the series definition prior to the equation, so that the model equation simply updated the cumulative sum from the previous series value. I was a little worried that the model equation object would not accept any Eviews commands.
(sample to stop when estimation starts)
series dlog_y = @nan(d(log(y)),0)
series pos_dlog_y = @pmax(dlog_y,0)
series sum_pos_dlog_y=@cumsum(pos_dlog_y)
(all sample)
{modelname}.append sum_pos_dlog_y = sum_pos_dlog_y(1)+pos_dlog_y
Your solution seems a little more elegant
Thank you for your help.
Who is online
Users browsing this forum: No registered users and 15 guests