Hi all, I have a seemingly simple question, but I cannot figure it out.
In short I am running a Dynamic Factor Model, in which the subtrends follow a random walk, and the (log) index values start and end at zero. Especially the ending part is an issue. If I wanted just the starting value to be zero I could easily do the following (just showing the subtrends for brevity);
parameters {
matrix[Nt-1,Nm] innovSub; // innovations of sub trends
vector<lower=0>[Nm] sigSub; // variance of sub trends
}
transformed parameters {
matrix[Nt,Nm] muSub; // latent trends
for(m in 1:Nm){
muSub[1,m] = 0;
for(t in 2:Nt){
muSub[t,m] = muSub[t-1,m] + innovSub[t-1,m]*sigSub[m];
}
}
However, note that in this code, the final period is not forced to be zero, which is costum in DFM literature. So somehow I want to incorporate something like this;
transformed parameters {
for(m in 1:Nm){
muSub[Nt,m] = 0;
}
}
Buy I am sure that adding this to the transformed parameter block in itself does not work. Likewise, adding something like -sum() to the final period would not work, as this violates the random walk. In other words, without the random walk structure I can think of multiple solutions, but now I am unsure how to solve it.
Many thanks in advance!
Alex