Skip to main content
. 2024 Feb 8;10:e1854. doi: 10.7717/peerj-cs.1854

Algorithm 1. Training the VAR model.

1: Input Parameters:
2: Data: a matrix where each column represents a time series variable.
3: Lag: define the Lag order.
4: num: represents the number of variables.
5: obs: represents the number of observations. STEP-1
6: for i to num do
7:  for j to Lag do
8:   Coefficient-matrix[i][j] = initial-weights
9:  end for
10: end for
   STEP-2
11: for i to num do
12:  for j to Lag do
13:   X = construct Lag_matrix(data[i], Lag)
14:   Y = data[i][Lag+1 : obs]
15:  end for
16:  Coefficient-matrix[i][j] = solve-coefficient (X, Y)
17: end for
   STEP-3
18: for i to num do
19:  for t = obs+1 to obs+Forcaststep do
20:   Popularity[i][t] = PredictPopularity (Coefficient-matrix[i],data[i][t-lag : t-1]
21:  end for
22: end for
   STEP-4
23: for i to num do
24:  Calculate RMSE for data[i][obs+1:obs +Forcaststep] and Popularity[i]
25: end for