diff --git a/stan/gptools/stan/gptools/graph.stan b/stan/gptools/stan/gptools/graph.stan index 89d117a..8faf9ea 100644 --- a/stan/gptools/stan/gptools/graph.stan +++ b/stan/gptools/stan/gptools/graph.stan @@ -49,6 +49,12 @@ vector gp_graph_conditional_loc_scale( int node, array [] int predecessors, real epsilon ) { int k = size(predecessors); + + // If there are no predecessors, we simply use the marginal distribution. + if (k == 0) { + return [0, sqrt(sigma ^ 2 + epsilon)]'; + } + matrix[1, k] cov12; matrix[k, k] cov22; if (kernel == 0) {