
Update the likelihood of observations given PDE parameters (Monte Carlo)
Source:R/func_calibrate.R
update_y_eta.RdFor a given candidate PDE parameter vector eta, simulates the
computer model output, computes the posterior predictive mean and covariance
at calibration locations using all nsam FFBS samples, and draws new
observations from the resulting predictive distribution.
Usage
update_y_eta(
eta,
nsam,
Nx,
Ny,
N_people,
nT_ori,
nT,
nT_cal,
N_sp,
N_sp_train,
AR_choice,
bncol,
res_ffbs,
n_b_cal,
ind_block_cal,
t_VinvY_FTheta_ls,
Vinv,
R_cal_train,
input,
input_cal,
phi_para,
gp_sigma2,
gp_tau2,
ind_train_cal
)Arguments
- eta
Numeric vector. PDE parameters (length 5).
- nsam
Integer. Number of posterior samples.
- Nx
Integer. Grid cells in x-direction.
- Ny
Integer. Grid cells in y-direction.
- N_people
Numeric. Total population size.
- nT_ori
Integer. Number of original time steps.
- nT
Integer. Number of episode time steps.
- nT_cal
Integer. Number of calibration time steps.
- N_sp
Integer. Total number of spatial locations.
- N_sp_train
Integer. Number of training spatial locations.
- AR_choice
Integer. AR order (1 or 2).
- bncol
Integer. Number of columns per block.
- res_ffbs
List. FFBS posterior samples.
- n_b_cal
Integer. Number of calibration blocks.
- ind_block_cal
Data frame. Block indices for calibration.
- t_VinvY_FTheta_ls
List. Precomputed \(V^{-1}(Y - F\Theta)\) terms.
- Vinv
Numeric matrix. Inverse of the observation covariance.
- R_cal_train
Numeric matrix. Correlation matrix for training locations.
- input
Numeric matrix. Observed location coordinates.
- input_cal
Numeric matrix. Calibration location coordinates.
- phi_para
Numeric scalar. GP range parameter.
- gp_sigma2
Numeric scalar. GP marginal variance.
- gp_tau2
Numeric scalar. GP nugget variance.
- ind_train_cal
Integer vector. Indices of training locations within calibration locations.
Value
A named list with:
- y
Array
c(nT_cal, N_sp_train, nsam)of predictive samples.- mu
Array
c(nT_cal, N_sp_train, nsam)of predictive means.- sigma2_cal
Numeric scalar. Predictive variance constant.
- Sigma
Numeric matrix. Predictive covariance matrix.
Lifecycle
Deprecated since spDBL 1.2.0 and will be removed in a future release.
The first call in a session warns; set
options(spDBL.warn_deprecated = FALSE) to silence it.
Examples
set.seed(1)
input <- matrix(runif(10), nrow = 5, ncol = 2)
res_ffbs <- lapply(1:12, function(e) array(rnorm(8), c(2, 2, 2)))
res_ffbs$Sigma <- c(0.2, 0.3)
args <- list(eta = c(0.3, 0.1, 0.01, 0.01, 0.01), Nx = 2, Ny = 3, N_people = 100,
nT_ori = 4, nT = 12, nT_cal = 3, N_sp = 6, N_sp_train = 4, AR_choice = 1,
bncol = 2, res_ffbs = res_ffbs, n_b_cal = 3,
ind_block_cal = generate_grid(1, 6, 1, 2),
t_VinvY_FTheta_ls = lapply(1:3, function(t) array(rnorm(60), c(6, 5, 2))),
Vinv = solve(gen_exp_kernel(input, phi = 2, sigma2 = 1.1, tau2 = 1e-4)),
R_cal_train = diag(4), input = input, input_cal = c(0.4, 0.6), phi_para = 2,
gp_sigma2 = 1.1, gp_tau2 = 1e-4, ind_train_cal = c(1, 3, 4, 6))
out <- do.call(update_y_eta, c(args, nsam = 2))
#> Warning: update_y_eta() is deprecated since spDBL 1.2.0 and will be removed in a future release. It comes from the original research code; new work should use calibration_prepare() and calibration_fit().
dim(out$y) # nT_cal x N_sp_train x nsam
#> [1] 3 4 2
out$sigma2_cal
#> [1] 0.1237689