Hello all,
I model theta
with the following:
lt += normal_lpdf(theta | C * to_vector(X[w,]),sigma_r);
where both C
and X
are both parameters matrices.
Now I am interested to orthogonalize C
with the QR decompositions and I do the following:
parameters {
.
.
real X[W,Xdim];
matrix[num_par, Xdim] C;
}
transformed parameters {
.
.
matrix[num_par, Xdim] C_Q; // declare the Q component of C
matrix[Xdim, Xdim] C_R; // declare the R component of C
C_Q = qr_thin_Q(C) * sqrt(num_par - 1);
C_R = qr_thin_R(C) / sqrt(num_par - 1);
}
model {
lt += normal_lpdf(theta | C_Q * C_R * to_vector(Xl[w,]),sigma_r);
}
So I have two questions:
- Is it even correct? All examples for the QR decomposition are on data matrices and not on parameters, so I am unsure if I can use the QR decomposition as if my parameters were data.
- After sampling, all vales of
C_R
arenans
. So obviously something is wrong. What am I missing?
Thanks!