when kg is as below
> kg
[1] "1992-01-01::2017-03-31"
kikan <- kg
plot(predict(lm(to.quarterly(SP5[kikan])[,1] ~ apply.quarterly(PA[kikan],mean) * apply.quarterly(UC[kikan],mean) * GDP[kikan] - apply.quarterly(UC[kikan],mean) )),type='l',col=2,axes=F,ylim=c(0,2500),ylab="")
par(new=T)
plot(to.quarterly(SP5[kikan])[,1],type='l',ylim=c(0,2500))
l <- 300 # length of sample period
a <- 6 # base for moving average
plot(last(seq(as.Date("1992-01-01"),as.Date("2017-05-01"),by="months"),n=(l-a)),na.trim(filter(diff(last(PA,n=l)),rep(1,a))/a),type='h',ylim=c(-800,300))
Below will overlay moving average upon actual. Don't forget to set 'l' and 'a'.
plot(last(seq(as.Date("1992-01-01"),as.Date("2017-05-01"),by="months"),n=(l-a)),na.trim(filter(diff(last(PA,n=l)),rep(1,a))/a),type='l',ylim=c(-800,500))
par(new=T)
plot(last(diff(PA),n=(l-a)),ylim=c(-800,500),col=2,type='h')
0 件のコメント:
コメントを投稿