Open
Conversation
Create a prediction function in generated quantities
adChong
reviewed
Nov 26, 2019
| for (i in 1:(n-1)) { | ||
| sigma_delta[i, i] = 1/lambda_delta + 1e-9; | ||
| for (j in (i+1):n) { | ||
| sigma_delta[i, j] = exp(-dot_self((xf[i] - xf[j]) .* beta_delta))/lambda_delta; |
| for (i in 1:(N-1)) { | ||
| sigma_eta[i, i] = 1/lambda_eta + sigma; | ||
| for (j in (i+1):N) { | ||
| sigma_eta[i, j] = exp(-dot_self((xt[i] - xt[j]) .* beta_eta))/lambda_eta; |
|
|
||
| // elements of sigma_eta | ||
| for (i in 1:(N-1)) { | ||
| sigma_eta[i, i] = 1/lambda_eta + sigma; |
|
|
||
| cov_y_pred = sigma_eta_pred + sigma_delta_pred; | ||
|
|
||
| // Evaluate COV{y(x_pred, tf)|y,.} = s22 - s21 s11{-1} s12 |
Owner
There was a problem hiding this comment.
align your comments with the code
| } | ||
| for (i in 1:n) { | ||
| for (j in 1:n_pred) { | ||
| k_x1_x2[i, j] = k_x1_x2[i, j] + exp(-dot_self((xt[i][1:p] - xt_pred[j][1:p]) .* beta_delta)) / lambda_delta; |
| for (i in 1:(n_pred-1)) { | ||
| sigma_delta_pred[i, i] = 1/lambda_delta + 1e-9; | ||
| for (j in (i+1):n_pred) { | ||
| sigma_delta_pred[i, j] = exp(-dot_self((xt_pred[i][1:p] - xt_pred[j][1:p]) .* beta_delta))/lambda_delta; |
| } | ||
|
|
||
| generated quantities { | ||
| vector[n_pred] f_pred = gp_pred_rng(n, N, n_pred, p, q, z, xf, xc, x_pred, tf, tc, beta_eta, lambda_eta, beta_delta, lambda_delta, sigma); |
|
|
||
| // elements of sigma_delta and add observation errors | ||
| for (i in 1:(n-1)) { | ||
| sigma_delta[i, i] = 1/lambda_delta + 1e-9; |
Owner
There was a problem hiding this comment.
set delta as a variable in the transformed data block instead of adding 1e-9 at every line
| row_vector<lower=0,upper=1>[p] rho_delta; | ||
| real<lower=0> lambda_eta; | ||
| real<lower=0> lambda_delta; | ||
| real<lower=0> sigma; |
Owner
There was a problem hiding this comment.
I'm confused by your use of sigma and delta.
Wouldn't sigma = 1/lambda_eta and delta is just a constant used to make the covariance matrix positive definite.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Create a prediction function in generated quantities