Hello everyone,
I wnat to generate a Series refering to the ''pefect foresight price'' of a stock index. The definition of this Price is as follows:
Let D and P be the Series of Real Dividends and Index Prices. Then the perfect foresight price of the strategy of holding the stock until the end of sample T, collecting the annual Dividends until T and selling it for the Price P_T (end of sample price) is sum_(j=0)^(T-t)(1/1+r)^(j+1)*D_(t+j) + (1/1+r)^(T-t)*P_T. sum_(j=0)^(T-t) menas in this case the sum of discounted dividends (r is the interest rate) from Observation t until the end of sample T. So for the first observation all dividends are included in this sum, for the second observation all dividends except for the first one and so on...
I have got two problems. First I don't know whether there is a sum operator in Eviews which computes for example in my case the sum of discounted dividends. Second, this sum is dynamic (different for every observation, since the holding periods become smaller and smaller for later observations since the time until the end of sample observation T decreases. Does anyone know the syntax for computing dynamic expressions like the one above?
Generating Series by mathimatical expression.
Moderators: EViews Gareth, EViews Steve, EViews Moderator, EViews Jason
-
EViews Glenn
- EViews Developer
- Posts: 2682
- Joined: Wed Oct 15, 2008 9:17 am
Re: Generating Series by mathimatical expression.
If I"m understanding correctly...
EViews has the @cumsum function which returns the backward cumulative sum, and the @sum function which returns the entire sum. You should be able to use results from these two functions and the lag operator to return the forward cumulative sum. (I think you'll also need to use @trend as well).
EViews has the @cumsum function which returns the backward cumulative sum, and the @sum function which returns the entire sum. You should be able to use results from these two functions and the lag operator to return the forward cumulative sum. (I think you'll also need to use @trend as well).
Re: Generating Series by mathimatical expression.
Could you give an example waht the exact comand would be? I am not realy into programing in eviews. Maybe you could just tell me the code for the first sum of the above expression.
-
EViews Glenn
- EViews Developer
- Posts: 2682
- Joined: Wed Oct 15, 2008 9:17 am
Re: Generating Series by mathimatical expression.
I didn't notice that you were re-basing the discount factor every period (though if I'd thought about your problem for more than a half second, I would have recognized it). Makes it a bit more difficult, but not overly so...
I think this will do it, though you should check the calculations for a few by hand. Basically, we reset the sample to the forward period in a loop and compute the sum through the end of the sample. Since each pass through the loop resets the sample forward, we overwrite the future values as we go.
Copy the snippet and put in in a program file and run it.
I think this will do it, though you should check the calculations for a few by hand. Basically, we reset the sample to the forward period in a loop and compute the sum through the end of the sample. Since each pass through the loop resets the sample forward, we overwrite the future values as we go.
Code: Select all
series firstterm
for !i = 0 to @obsrange-1
smpl @first+!i @last
firstterm = @sum(( (1 + r)^(@trend + 1 - i)) * D)
next
Re: Generating Series by mathimatical expression.
Hello everyone,
I'm refreshing this topic. I am trying to build a time serie for "permanent" military spending, following Robert Barro (1981, 1986, 1987).
Here's the definition:
\overline{g}_{t} = (1 - \rho) \sum_{s = 0}^{T} \rho^s \mathbb{E}_t g_{t+s}
where g_t is military spending/GDP. Basically this ratio is represented by a stationary AR(2).
Then, to compute this sum for each observation t, I forecast g_t+h for all horizon h, up to a large H, conditional on information at date t.
The problem is I have some trouble building a correct loop to compute this sum; and former answers to this topic did not help me.
Especially, I have trouble with this loop :
Thanks in advance for any help.
I'm refreshing this topic. I am trying to build a time serie for "permanent" military spending, following Robert Barro (1981, 1986, 1987).
Here's the definition:
\overline{g}_{t} = (1 - \rho) \sum_{s = 0}^{T} \rho^s \mathbb{E}_t g_{t+s}
where g_t is military spending/GDP. Basically this ratio is represented by a stationary AR(2).
Then, to compute this sum for each observation t, I forecast g_t+h for all horizon h, up to a large H, conditional on information at date t.
The problem is I have some trouble building a correct loop to compute this sum; and former answers to this topic did not help me.
Especially, I have trouble with this loop :
Code: Select all
'Program to compute temporary military spending, following Barro (1981) definition of permanent spending with an AR(2) process for military outlays/GDP
'Estimate AR(2) process for military outlays/GDP
smpl 1791 2012
equation ar2_mil_outlays.ls military_outlays c military_outlays(-1) military_outlays(-2)
'Compute the permanent military outlays/GDP using conditional forecast for each date i and each horizon j
series perm_mil_outlays
pagestruct(end=2012+!horizon)
!horizon = @obsrange
for !i = 0 to !horizon-1
smpl @first+!i @first+!horizon+!i
ar2_mil_outlays.forecast military_outlays_for
series perm_mil_outlays
for !j = 0 to !horizon
perm_mil_outlays = 0.02 * @sum( (0.98^!j)*military_outlays_for )
next
next
smpl 1791 2012
pagestruct(end=2012)Who is online
Users browsing this forum: No registered users and 2 guests
