Hi everyone,
I’m trying to estimate an NxN matrix A that satisfies A*x = b, where I know the vectors x and b (of dimension N). But it also must satisfy D*xm = bm, where D is the submatrix of A comprised of the first M rows and columns (D = A[1:M,1:M]), where I also know the vectors xm and bm (of dimension M).
To do this I set some priors for A, calculate inverse(A)*b, and compare this to the observed x. I also create the submatrix D = A[1:M,1:M] from A, and calculate inverse(D)*bm.
What I’m unsure of is whether or not I need to do a Jacobian correction for this, and if so, how exactly. Not only is it a complex nonlinear transformation of A, but the entries of A appear both in inverse(A) and inverse(D).
Any thoughts would be much appreciated!
Thanks,
John
MODEL:
data {
int N;
int M;
vector[N] x;
vector[N] b;
vector[M] xm;
vector[M] bm;
}
parameters {
real<lower=0> sigma;
matrix[N,N] A;
}
transformed parameters{
matrix[M,M] D;
vector[N] x_est;
vector[M] xm_est;
// create the submatrix of A, using the first M rows and cols
for(i in 1:M){
for(j in 1:M){
D[i,j] = A[i,j];
}
}
// get the solution for the full matrix
x_est = inverse(A)*b;
// get the solution for the submatrix
xm_est = inverse(D)*bm;
}
model {
sigma ~ normal(0,1);
// set priors on A
for(i in 1:N){
for(j in 1:N){
A[i,j] ~ normal(0,1);
}
}
// compare the fit for the full matrix
for(i in 1:N){
target += normal_lpdf(x[i] | x_est[i], sigma);
}
// compare the fit for the submatrix
for(i in 1:M){
target += normal_lpdf(xm[i] | xm_est[i], sigma);
}
}