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]
st: Tssmooth Ma Missing Values
From
<[email protected]>
To
<[email protected]>
Subject
st: Tssmooth Ma Missing Values
Date
Thu, 25 Mar 2010 10:54:31 -0000
I'm trying to generate 2 and 5 year forward and backward moving averages for a particular variable. A sample of the data structure appears below. To generate the moving averages below I have used the following syntax:
tssmooth ma 2yearMA=Variable, window(0 1 1)
tssmooth ma 5yearMA=Variable, window(0 1 4)
tssmooth ma Back2YearMa=Variable, window(1 1 0)
The problem I encounter is that the forward moving average syntax leads Stata to create new values prior to the start of the times in rows where I am missing data for the variable. At the end of the time series the same occurs for the backward moving average. Ideally, I want Stata to produce moving averages only in years for which I have data for the variable.
Is there some syntax I could use to tell Stata not to create these new values in rows where I have missing data?
Country Year Variable 2yearMA 5YearMa Back2YearMa
Australia 1897 . . 0 .
Australia 1898 . . 0.5 .
Australia 1899 . . 1 .
Australia 1900 . 0 1.5 .
Australia 1901 0 0.5 2 .
Australia 1902 1 1.5 3 0
Australia 1903 2 2.5 4 0.5
Australia 1904 3 3.5 5 1.5
Australia 1905 4 4.5 6 2.5
Australia 1906 5 5.5 7 3.5
Australia 1907 6 6.5 8 4.5
Australia 1908 7 7.5 9 5.5
Australia 1909 8 8.5 10 6.5
Australia 1910 9 9.5 11 7.5
Australia 1911 10 10.5 12 8.5
Australia 1912 . . . 9.5
Please access the attached hyperlink for an important electronic communications disclaimer: http://www.lse.ac.uk/collections/planningAndCorporatePolicy/legalandComplianceTeam/legal/disclaimer.htm
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/