extract(fit3, pars = c("f")) should give you access to the samples of f. It can be a bit of a bear to get everything lined up right for plotting. You can wrestle with ggplot yourself, or there’s at least this library: https://github.com/mjskay/tidybayes#fit-curves (from @mjskay) out there to make it easier.
You can make your model a little cleaner by building f in a transformed parameters block (variables in there are accessible by model and generated quantities blocks).
Something like:
transformed parameters {
vector[N] f;
{
matrix[N, N] K = cov_exp_quad(x, alpha, rho);
matrix[N, N] L_K;
// diagonal elements
for (k in 1:N)
K[k, k] = K[k, k] + delta;
L_K = cholesky_decompose(K);
f = L_K * eta;
}
}
model {
rho ~ gamma(4, 4);
alpha ~ normal(0, 1);
sigma ~ normal(0, 1);
eta ~ normal(0, 1);
y ~ normal(f, sigma);
}
generated quantities {
vector[N] yhat;
for(n in 1:N)
yhat[n] = normal_rng(f[n], sigma);
}
edits: fixed a couple code typos
Or is it making predictions at new points that you want?