Reputation: 1079
Hi am ploting a xts object:
And I would like to extend the xlim til 30-february because I want to add the prediction from an Arima model:
par(mfrow=c(1,1))
pred <- predict(try2, n.ahead = 1,se.fit=T)
lim_sup <- pred$pred + 1.96 * pred$se
lim_inf <- pred$pred - 1.96 * pred$se
plot(heat["1996-02-01 00:00/1996-02-16 04:00"],type="l",main="Cross Validation")
points(exp(pred$pred),col="blue",lwd=2)
points(exp(lim_sup),lwd=2,col="green")
points(exp(lim_inf),lwd=2,col="green")
But I can not see any lines in the plot. Could you give me some recommendation?
The heat time series looks like this
HC.f
1996-02-01 00:00:00 1437.000
1996-02-01 01:00:00 1441.600
1996-02-01 02:00:00 1489.300
1996-02-01 03:00:00 1501.300
1996-02-01 04:00:00 1568.400
1996-02-01 05:00:00 1629.400
While the predictions for one hour step:
pred$pred
Time Series:
Start = 3002
End = 3002
Frequency = 1
[1] 7.480588
Upvotes: 3
Views: 1902
Reputation: 176648
Merge your actual and prediction objects before plotting. Then you will have one time series over the full desired time period.
library(xts)
set.seed(21)
x <- xts(rnorm(10),Sys.Date()-10:1)
y <- xts(rnorm(3),Sys.Date()+0:2)
z <- merge(x,y)
plot(z[,1], ylim=range(z,na.rm=TRUE))
lines(z[,2],col='red')
Upvotes: 3