I am trying to fit a Bayesian Dynamic Factor Model and I have gone through Jim Savage’s example http://modernstatisticalworkflow.blogspot.com/2016/08/a-brief-introduction-to-dynamic-factor.html for the Dynamic Factor Model and http://modernstatisticalworkflow.blogspot.com/2017/04/hierarchical-vector-autoregression.html for his hierarchical vector autoregressive model.
I am having issues with incorporating a lagged time for the common factors. My model is
Y_{i,t} = \nu + \lambda \eta_{i,t} + \epsilon_{i,t},
where
\eta_{i,t} = \alpha + B\eta_{i,t-1} + \zeta_{it}.
In this case, I have 6 observed variables with 2 factors. That is, a common factor to 3 observed variables only.
data {
int N_Y; //number of observed variables
int N_T; //number of time points
int N_I; //number of individuals
int N; //number of rows
matrix[N, N_Y] Y1; //observed variables
int ID[N]; //Participant ID variable
int Time[N]; //Time variable
}
parameters {
vector[6] nu; //intercept
vector[4] lambda; //loadings
matrix[N,2] eta; //factor
//OR
real eta1[N_I, N_T,2]; //alternative factor
}
So this is where I am having my struggles, do I specify my factor loadings as a matrix of 3D array to account for the time lag within a person. I am not building a hierarchical model in this case but I need the time lags to only show within a person and not as
for(t in 1:N_T){
for(j in 1:2){
eta[t,j] = alpha[j] + B[j]*eta[t-1,j];
}
}
Because in this case, Person 2’s time 1 depends on Person 1’s last time, which I am trying to prevent.
If I go with the 3d array I am unable to write the distribution in Stan as \eta \sim MVN(0, \psi), and \psi is a 2 \times 2 covariance matrix.