This is an old version, view current version.

## 15.3 Complex linear regression

Complex valued linear regression with complex predictors and regression coefficients looks just like standard regression. For example, if we take x to be predictors, y to be an array of outcomes. For example, consider the following complete Stan program for an intercept and slope.

data {
int<lower=0> N;
array[N] complex x;
array[N] complex y;
}
parameters {
complex alpha;
complex beta;
}
model {
for (n in 1:N) {
complex eps_n = y[n] - (alpha + beta * x[n]);  // error
eps_n ~ // ...error distribution...
}
}

The question remains of how to fill in the error distribution and there are several alternatives. We consider only two simple alternatives, and do not consider penalizing the absolute value of the error.

### 15.3.1 Independent real and imaginary error

The simplest approach to error in complex regression is to give the real and imaginary parts of eps_n independent independent normal distributions, as follows.

parameters {
// ...
vector[2] sigma;
}
// ...
model {
// ...
to_real(eps_n) ~ normal(0, sigma[1]);
to_imag(eps_n) ~ normal(0, sigma[2]);
sigma ~ //...hyperprior...
}

A new error scale vector sigma is introduced, and it should itself get a prior based on the expected scale of error for the problem.

### 15.3.2 Dependent complex error

The next simplest approach is to treat the real and imaginary parts of the complex number as having a multivariate normal prior. This can be done by adding a parameter for correlation to the above, or just working with a multivariate covariance matrix, as we do here.

parameters {
cholesky_factor_corr[2] L_Omega;  // correlation matrix
vector[2] sigma;           // real, imag error scales
// ...
}
// ...
model {
eps_n ~ multi_normal_cholesky([0, 0]',
diag_pre_multiply(sigma, L_Omega));
L_Omega ~ lkj_cholesky(4);  // shrink toward diagonal correlation
sigma ~ // ... hyperprior ...
}

Here, the real and imaginary components of the error get a joint distribution with correlation and independent scales. The error gets a multivariate normal distribution with zero mean and a Cholesky factor representation of covariance, consisting of a scale vector sigma and a Cholesky factor or a correlation matrix, L_Omega. The prior on the correlations is concentrated loosely around diagonal covariance, and the prior on the scales is left open.