And to answer the Stan question, it's not a syntactic issue, but
a semantic one. You probably don't want to parameterize like this:
> parameters {
>> cov_matrix[k] V;
>> cov_matrix[k] beta;
>> cov_matrix[k] mu;
>> vector<lower=0>[k] seasonal;
>> }
>> transformed parameters{
>> cov_matrix[param] W;
>> W <- rep_matrix(0, param, param);
>>
>> for(i in 1:k)
>> for(j in 1:k)
>> W[i,j]<-beta[i,j];
>>
>> for(i in 1:k)
>> for(j in 1:k)
>> W[i+k,j+k]<-mu[i,j];
>>
>> W[5,5]<-seasonal[1];
>> W[16,16]<-seasonal[2];
I don't know what k is, but it's problematic no matter what
it is.
The first two loops would be fine if param = 2 * k and you stopped
there. You'd get a block diagonal matrix made up out of covariance
matrices, so it'll still be positive definite.
But when you set W[5,5] and W[16,16], all bets are off (assumm
I'd suggest doing this the other way around, and setting
seasonal as a transformed parameter and setting
seasonal[1] <- W[5,5];
seasonal[2] <- W[16,16];
I also wouldn't recommend hard-coding numbers like 5 and 16 and
then using values like k. Either do everything relative to k or
hard-code k, too.
Unless gaussian_dlm_obs puts priors on the covariance matrices,
you'll also have improper priors (which is OK as long as
the posteriors are proper, but can cause computational difficulties
if estimates tend toward boundaries).
- Bob