Skip to content

Create a prediction function#9

Open
NUSSongChao wants to merge 1 commit intoadChong:masterfrom
NUSSongChao:master
Open

Create a prediction function#9
NUSSongChao wants to merge 1 commit intoadChong:masterfrom
NUSSongChao:master

Conversation

@NUSSongChao
Copy link
Contributor

Create a prediction function in generated quantities

Create a prediction function in generated quantities
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;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alignment (too many spaces)

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;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alignment (too many spaces)


// elements of sigma_eta
for (i in 1:(N-1)) {
sigma_eta[i, i] = 1/lambda_eta + sigma;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alignment (too many spaces)


cov_y_pred = sigma_eta_pred + sigma_delta_pred;

// Evaluate COV{y(x_pred, tf)|y,.} = s22 - s21 s11{-1} s12
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

too long. use next line

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;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

too long used next line

}

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);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

too long use next line


// elements of sigma_delta and add observation errors
for (i in 1:(n-1)) {
sigma_delta[i, i] = 1/lambda_delta + 1e-9;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants