model {
# No noise for spline in time
        for (i in 1:n_obs) {
          # Main likelihood
          y[i] ~ dnorm(mu_y[i], sigmasq_all[i]^-1)
          sigmasq_all[i] <- sigma_y^2 + y_err[i]^2

          # Mean structure
          mu_y[i] <- r[i]

          # Pulling out residuals of model
          residuals[i] <- y[i] - mu_y[i]
          }

      # No penalty Regional term
      #r <- B_t %*% b_t
      # for (j in 1:n_knots_t) {
      #   #b_t[j] ~ dnorm(0, tau_t)
      #  b_t[j] ~ dnorm(0, sigma_t^-2)
      # }

      # Spline in time penalised 1st order
      r <- B_t %*% b_t
      b_t[1] ~ dnorm(0,1)
      for (j in 2:n_knots_t) {
        b_t[j] ~ dnorm(b_t[j-1], sigma_beta^-2)
      }

       # 1st order difference on b_t for Regional term
       #r <- B_t %*% b_t
       #for (j in 1:(n_knots_t-1)) {
       #for (j in 1:(n_knots_t)) {
        # b_t[j] ~ dnorm(0, tau_t)
         #b_t[j] ~ dnorm(0, sigma_t^-2)
       #}
        #---Sum to 0 constraint on the final knot---
        #b_t[n_knots_t] <- -sum(b_t[1:(n_knots_t-1)])


      # Priors
      sigma_beta~ dt(0, 1^-2, 1)T(0,)
      sigma_y ~ dt(0, 1^-2, 1)T(0,)

      }
