title: Plotting predicted value and raw score of a time series in R
body: <p>I am now using the "vars" package in R to examine the interrelationship between two time series. Specifically, our data has 66 time points. I divided it into test sample (1-60 observations) and hold-out sample (61-66 observations). I want to plot the predicted value of all 66 observations with the raw score of all 66 observations along the same scale (from 1 to 66) in the same plot to compare the model fit. But I failed to do so with par and layout function. It is highly appreciated if you can kindly give me some instructions on it.</p>
  
  <p>Below is my R code:</p>
  
  <pre><code>library("vars")
  setwd("c:$temp")  
  filename&lt;-"data.txt"
  full&lt;-read.table(filename,header=TRUE,sep="\t")
  env&lt;-full[1:60,]
  varlag1&lt;-VAR(env,p = 2,type = "const");
  summary(varlag1)
  plot(varlag1)
  predict&lt;-predict(varlag1,n.ahead=6,ci=0.95)
  list(predict)
  raw_v1&lt;-full[1:66,1]
  plot(predict,names="v1",lwd=3)
  par(new=TRUE)
  plot(as.ts(raw_v1),lwd=1)
  raw_v2&lt;-full[1:66,2]
  plot(predict,names="v2",lwd=3)
  par(new=TRUE)
  plot(as.ts(raw_v2),lwd=1)
  </code></pre>