I am using the VARS package in R and the dataset Canada found in the package itself. I am not understanding the reason why the fitted model has 2 data points less than the actual time series Canada. The Canada time series is of size 84*4 whereas the fitted are of size 82*4. I am using the following code:
library(vars)
rm(list=ls(all=TRUE))
data(Canada)
#to plot the time series
par(mfrow=c(1, 1))
plot(Canada, plot.type="m", mar=c(gap=0.3, 5.1, gap=0.3, 2.1))
#VARselect used to get the order of the time series
VARselect(Canada, lag.max = 5, type="const")
#VAR(2) estimation
var.2c <- VAR(Canada, p = 2, type = "const")
fitted(var.2c)
The parameter p
is for the lag order, and if p = 2
, and the time series has 84 observations, then the observations used in VAR must be 84 - 2 = 82
You can change p
and see what happens:
var.2c <- VAR(Canada, p = 1, type = "const")
fitted(var.2c)
var.2c$obs
# 83
https://www.rdocumentation.org/packages/vars/versions/1.5-2/topics/VAR