The dimensions are screwing with me here.
Let’s say that we have N data points and M covariates, where
N >> M. In this case our original problem is
matrix[N, M] X; // data
vector[M] beta; // parameters
vector[N] alpha; // parameters
y ~ normal(X * beta + alpha, sigma);
If the covariates are highly correlated then this can cause
problems, so instead we want to use a QR decomposition,
to write
X * beta = (Q * R) * beta = Q * (R * beta) = Q * beta_tilde
and then fit the model
matrix[N, M] X; // data
matrix[N, N] Q;
matrix[N, M] R;
vector[N] beta_tilde; // parameters
vector[N] alpha; // parameters
y ~ normal(Q * beta_tilde + alpha, sigma);
beta = R \ beta_tilde;
But doesn't this replace the M original parameters with N >> M
new parameters? Is the cost of decor relating really the
introduction of so many new parameters?
In any case qr_R is seg faulting on me so it looks like there
are bigger problems...