Periodic Gaussian Process - covariance matrix not positive semidefinite

Sorry for the late reply–you could also use the spectral mixture kernel (https://arxiv.org/pdf/1302.4245.pdf). Here is Stan code for a two component mixture (i.e. an additive kernel with two different periodic components) in case it’s helpful to someone.

  matrix[n1, n1] Sigma1;

  for (i in 1:n1) {
    Sigma1[i, i] <- var1 + var2;
    for (j in (i+1):n1) {
      Sigma1[i, j] <- var1 * exp(-(x1[i]-x1[j])^2*bw1) * cos(twopi * fabs(x1[i] - x1[j]) * period1) +
                      var2 * exp(-(x1[i]-x1[j])^2*bw2) * cos(twopi * fabs(x1[i] - x1[j]) * period2);
      Sigma1[j, i] <- Sigma1[i, j];
    }
  }
2 Likes