Zeitreihenanalyse - Übung 6

From StatWiki
Jump to: navigation, search

Retail and Food Services Sales

Fit a linear trend and a sinusoid with period 12 to the not seasonally adjusted Retail and Food Services Sales.

Retail and Food Services Sales

Fit a linear trend and six sinusoids to the not seasonally adjusted Retail and Food Services Sales.

Shift one of the two graphs in the previous exercise to avoid an overlap. Do not plot the y-axis, because it is not meaningful for the shifted graph.

Convert.php: File "/var/www/localhost/htdocs/StatWiki/Rfiles/R/ed4d8d480f1ad97f944abeec3915c8355a0d4f11_0.pdf.png" does not exist
in

pdf(rpdf) rsa=readdataSK("RSAFSNA.csv", "csv") N=nrow(rsa) rsa=data.frame(year=as.numeric(substr(rsa$DATE,1,4)), y=log(rsa$VALUE), t=1:N) omega = 2*pi/12

y.sin6 <- lm(y~t +cos(omega*t)+sin(omega*t)

                   +cos(2*omega*t)+sin(2*omega*t)
                   +cos(3*omega*t)+sin(3*omega*t)
                   +cos(4*omega*t)+sin(4*omega*t)
                   +cos(5*omega*t)+sin(5*omega*t)
                   +cos(6*omega*t),data=rsa)

plot(1992+(0:(N-1))/12,rsa$y,type="l",xlab="Time",ylab="Retail and Food Services Sales", ylim=c(11.8,13.4)) lines(1992+(0:(N-1))/12,fitted(y.sin6),col=2)

plot(1992+(0:(N-1))/12,rsa$y,type="l",xlab="Time",ylab=" ", ylim=c(11.8,13.4)) lines(1992+(0:(N-1))/12,fitted(y.sin6)+0.3,col=2)