Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
annoporci <annoporci@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: generate the level series from the growth rate series |

Date |
Fri, 04 Jan 2013 23:24:00 +0800 |

Nick:

with thanks, --- Patrick Toche. On Fri, 04 Jan 2013 19:36:33 +0800, Nick Cox <njcoxstata@gmail.com> wrote:

In your code -change- is ambiguous as between -change2- and -change3-.Evidently, levels can be reconstructed from changes given an initialvalue:. sysuse sp500 (S&P 500) . gen close2 = close[1] + sum(change) . assert close == close2 If in your real data you have _percent_ changes (assuming equally spaced times and no missings or omissions) gen double level = 100 replace level = level[_n-1] * (1 + pcchange / 100) if _n > 1 This generalises to panels: bysort panelid (time) : replace level = level[_n-1] * (1 + pcchange / 100) if _n > 1 Nick Patrick Toche <annoporci@gmail.com> wrote: (2)I will take 100 as a starting value to create an index.In the sp500 example, I used the value from the dataset so I couldquicklycheck that my calculations were correct, hence: replace close2 = 1283.27 in 1 where 1283.27 is the value of "close[_n]" in the dataset.(1)This must be a very simple question... I have data for percentage changes and would like to reconstruct the levels of the variables.Taking the sp500 dataset, I show below that I can generate theone-perioddifference series for the level variable "close", with and withouttsset.Then I try to reverse-engineer to recover the level variable "close"fromthe difference series named "change", but I get stuck. sysuse sp500 gen change2 = close-close[_n-1] /// method without tsset gen t=_n tsset t gen change3 = close-L.close /// method with tsset gen close2 = . replace close2 = 1283.27 in 1 /// assign the first value replace close2 = close2[_n-1]+change /// try to recover the level This last step fails. I'd appreciate your help very much.* * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/

-- Patrick Toche. * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/

**References**:**st: generate the level series from the growth rate series***From:*annoporci <annoporci@gmail.com>

**Re: st: generate the level series from the growth rate series***From:*Nick Cox <njcoxstata@gmail.com>

**Re: st: generate the level series from the growth rate series***From:*annoporci <annoporci@gmail.com>

**Re: st: generate the level series from the growth rate series***From:*Nick Cox <njcoxstata@gmail.com>

- Prev by Date:
**st: how to do balancing test in diff command** - Next by Date:
**Re: st: Comparison of robust and cluster-robust standard errors when the number of clusters is small** - Previous by thread:
**Re: st: generate the level series from the growth rate series** - Next by thread:
**st: level and distribution plot side by side** - Index(es):