I need to generate an AR(2) model from a given csv file
I understand
we use
dt = fread("homewares.csv")
sub_dt <- fread("fhomewares.csv")
start_date <- "2000-01-01"
cutoff_date <- "2016-12-31"
end_date <- "2020-12-31"
to load the file and get a data set for specific range.
But I also must generate the two lags of the dependent variables before sub setting the data, so that my effective data sample in the regressions start from January 2000.
I understand how to simulate it without a csv but I cannot for the life of me figure out how to generate an AR(2) model given a variable in the data table.
I need the model: A[t] = alpha0 + alpha1 * A[t-1] + alpha2 * A[t-2] +e[t]
What is code I need?
Thanks