compute_posterior_m_nn {GPCERF}R Documentation

Calculate posterior means for nnGP model

Description

Calculates the posterior mean of a point on the CERF based on the nnGP model. This function also returns the weights assigned to all nearest neighbors when calculating the posterior mean.

Usage

compute_posterior_m_nn(
  hyperparam,
  w,
  gps_w,
  obs_ord,
  y_obs_ord,
  kernel_fn = function(x) exp(-x^2),
  n_neighbor = 10,
  block_size = 10000
)

Arguments

hyperparam

A set of hyperparameters in the GP model.

w

A scaler representing the exposure level for the point of interest on the CERF.

gps_w

The GPS for all samples when their exposure levels are set at w.

obs_ord

A matrix of two columns. First column is the observed exposure levels of all samples; second is the GPS at the observed exposure levels. The rows are in ascending order for the first column.

y_obs_ord

A vector of observed outcome values. The vector is ordered as obs_ord.

kernel_fn

The covariance function of the GP.

n_neighbor

The number of nearest neighbors on one side.

block_size

Number of samples included in a computation block. Mainly used to balance the speed and memory requirement. Larger block_size is faster, but requires more memory.

Value

TODO: The first column is the selected index and the second column is weight. A two-column matrix. The first column is the weights assigned to each nearest neighbor. The second column is the corresponding observed outcome value. The weight in the last row of this matrix is NA and the observed outcome value is the estimated posterior mean of the CERF at point w, which is the weighted sum of all observed outcome values of the neighbors.


[Package GPCERF version 0.2.4 Index]