# 1.2 Linear Filtering of Time Series (Solution to Homework) # Ex. 1.9 (Public Expenditures Data) West Germany's public expenditures (in billion D-Marks) # between 1961 and 1990. Compute simple moving averages of order 3 and 5 to estimate a possible # trend. Plot the original data as well as the filtered ones and compare the curves. pubexpen <- ts(read.table("pubexpen.txt")[,2],start=1961) pubexpen pubexpen.star.3 <- filter(pubexpen,filter=c(1,1,1)/3) pubexpen.star.5 <- filter(pubexpen,filter=c(1,1,1,1,1)/5) plot(pubexpen) lines(pubexpen.star.3,col="red") lines(pubexpen.star.5,col="blue")