| Title: | Bayesian Zero-Inflated Negative Binomial Gaussian Process Models |
|---|---|
| Description: | Fits Bayesian zero-inflated negative binomial regression models with Gaussian process random effects for spatial, temporal, or spatiotemporal count data. Provides Markov chain Monte Carlo sampling, configurable random effects in the zero-inflation and count components, and posterior predictive draws. Implements a full GP version of the methods described by He and Huang (2024) <doi:10.1016/j.jspi.2023.106098>. |
| Authors: | Mahlon Scott [aut], Qing He [aut], Hsin-Hsiung Huang [aut, cre, cph] (ORCID: <https://orcid.org/0000-0001-7150-7229>) |
| Maintainer: | Hsin-Hsiung Huang <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.0.0 |
| Built: | 2026-10-15 09:36:45 UTC |
| Source: | https://github.com/kingjms1/gp_zinb_r |
Finds reasonable upper/lower bounds on gp parameters ensuring matrices remain pd invertible
gp_param_bounds(Ds, Dt, kernel, tolerance = 1e-10)gp_param_bounds(Ds, Dt, kernel, tolerance = 1e-10)
Ds |
Spatial distance matrix |
Dt |
Temporal distance matrix |
kernel |
Kernel function accepting a distance matrix and a length scale. |
tolerance |
Numerical tolerance used to assess matrix invertibility. |
A list containing the upper bounds ltmax and lsmax for the
temporal and spatial length scales, respectively.
Creates the kernel matrix exp(-dist / ls^2).
kernel(dist, ls)kernel(dist, ls)
dist |
Numeric distance matrix. |
ls |
Positive length scale. |
A numeric kernel matrix with the same dimensions as dist.
distances <- as.matrix(stats::dist(c(0, 1, 3))) kernel(distances, ls = 2)distances <- as.matrix(stats::dist(c(0, 1, 3))) kernel(distances, ls = 2)
Creates the augmented distance matrices needed for Gaussian-process
conditioning and indicator matrices mapping prediction observations to
unique new spatial and temporal levels. The first observed level in each
dimension is the baseline omitted by ZINB_GP() and is therefore excluded
from the augmented distance matrix.
make_prediction_inputs( coords = NULL, time_coords = NULL, coords_new = NULL, time_coords_new = NULL )make_prediction_inputs( coords = NULL, time_coords = NULL, coords_new = NULL, time_coords_new = NULL )
coords |
Observed spatial coordinate matrix, including the baseline as
its first row. Use |
time_coords |
Observed temporal coordinate matrix, including the
baseline as its first row. A numeric vector is treated as a one-column
matrix. Use |
coords_new |
Spatial coordinates for the prediction observations, with one row per row of the new fixed-effect design matrix. Repeated rows share one predicted spatial random effect. |
time_coords_new |
Temporal coordinates for the prediction observations, with one row per row of the new fixed-effect design matrix. A numeric vector is treated as a one-column matrix. Repeated rows share one predicted temporal random effect. |
A list containing Ds_new, Dt_new, Vs_new, and Vt_new.
Each non-NULL distance matrix covers the observed nonbaseline levels
followed by the unique new levels. Each design matrix has one row per
prediction observation and one column per unique new level.
observed_space <- rbind(c(0, 0), c(1000, 0), c(0, 1000)) observed_time <- c(0, 100) new_space <- rbind(c(500, 500), c(500, 500), c(750, 250)) new_time <- c(150, 200, 150) prediction_inputs <- make_prediction_inputs( coords = observed_space, time_coords = observed_time, coords_new = new_space, time_coords_new = new_time ) prediction_inputs$Vs_new prediction_inputs$Vt_newobserved_space <- rbind(c(0, 0), c(1000, 0), c(0, 1000)) observed_time <- c(0, 100) new_space <- rbind(c(500, 500), c(500, 500), c(750, 250)) new_time <- c(150, 200, 150) prediction_inputs <- make_prediction_inputs( coords = observed_space, time_coords = observed_time, coords_new = new_space, time_coords_new = new_time ) prediction_inputs$Vs_new prediction_inputs$Vt_new
Create y, along with spatial and temporal design matrices from an observation matrix.
make_y_Vs_Vt(obs_matrix)make_y_Vs_Vt(obs_matrix)
obs_matrix |
s by t matrix, where s is the number of locations, t is the number of times, each entry of the matrix is a nonnegative integer. |
A list with the following elements:
The observation matrix flattened in column-major order.
Spatial design matrix mapping observations to locations.
Temporal design matrix mapping observations to times.
counts <- matrix(c(0, 1, 2, 0, 1, 3), nrow = 2) design <- make_y_Vs_Vt(counts) design$y design$Vs design$Vtcounts <- matrix(c(0, 1, 2, 0, 1, 3), nrow = 2) design <- make_y_Vs_Vt(counts) design$y design$Vs design$Vt
Use SVD for precision matrix to sample from multivariate normal distribution
mvn_sample_svd(P_svd, mu, entropy = NULL, threshold = 1e-12)mvn_sample_svd(P_svd, mu, entropy = NULL, threshold = 1e-12)
P_svd |
SVD of precision matrix |
mu |
Mean of MVN to draw from |
entropy |
Draw from MVN of correct size (can be used to draw all mvns at once for efficiency) |
threshold |
Singular values at or below this threshold are discarded. |
A draw from the multivariate normal distribution with precision
matrix represented by P_svd.
Creates noise_ratio * A + (1 - noise_ratio) * I.
noise_mix(A, noise_ratio)noise_mix(A, noise_ratio)
A |
Numeric square matrix. |
noise_ratio |
Numeric mixing ratio between zero and one. |
A numeric square matrix with the same dimensions as A.
correlation <- matrix(c(1, 0.5, 0.5, 1), nrow = 2) noise_mix(correlation, noise_ratio = 0.8)correlation <- matrix(c(1, 0.5, 0.5, 1), nrow = 2) noise_mix(correlation, noise_ratio = 0.8)
Returns default if value is null
nullcheck(value, default)nullcheck(value, default)
value |
Nullable |
default |
Default value |
Generates posterior predictive draws at new spatial locations, times, or both. For every retained MCMC iteration, the method draws each active random effect from its GP predictive distribution conditional on the stored fitted random effect, adds it to the corresponding fixed-effect predictor, and draws a zero-inflated negative-binomial response.
## S3 method for class 'zinb_gp_fit' predict( object, X, Ds_new = NULL, Dt_new = NULL, Vs_new = NULL, Vt_new = NULL, kern = NULL, ... )## S3 method for class 'zinb_gp_fit' predict( object, X, Ds_new = NULL, Dt_new = NULL, Vs_new = NULL, Vt_new = NULL, kern = NULL, ... )
object |
A fitted zinb_gp_fit object returned by ZINB_GP(). |
X |
Fixed-effect design matrix for the prediction observations. |
Ds_new |
Augmented spatial distance matrix produced by make_prediction_inputs(), or NULL for a temporal-only fit. |
Dt_new |
Augmented temporal distance matrix produced by make_prediction_inputs(), or NULL for a spatial-only fit. |
Vs_new |
Spatial design matrix produced by make_prediction_inputs(). |
Vt_new |
Temporal design matrix produced by make_prediction_inputs(). |
kern |
Kernel function used to fit the model. The default is kernel(); supply the fitting kernel again if a custom kernel was used. |
... |
Unused. |
An object of class zinb_gp_prediction containing posterior draws Y_pred, eta_at_risk, and eta_count. Active predicted GP effects are returned under A, B, C, and D, matching the fitted object.
# Fit a small spatial model, then predict at two new locations. cells <- expand.grid(spatial = seq_len(4), replicate = seq_len(12)) Vs <- diag(4)[cells$spatial, -1, drop = FALSE] y <- c( 0, 0, 0, 0, 15, 1, 0, 0, 6, 0, 0, 0, 1, 6, 0, 0, 0, 0, 0, 1, 11, 0, 0, 0, 2, 0, 0, 0, 8, 0, 5, 0, 0, 4, 0, 0, 34, 0, 1, 0, 0, 2, 0, 1, 0, 0, 0, 3 ) X <- cbind("(Intercept)" = 1, x = as.numeric(scale(seq_along(y)))) coords <- rbind(c(0, 0), c(1000, 0), c(0, 1000), c(1000, 1000)) set.seed(1) fit <- ZINB_GP( X = X, y = y, coords = coords, nsim = 5, burn = 1, thin = 2, use_count_gp = TRUE, use_inflation_gp = FALSE, Vs = Vs, Ds = as.matrix(stats::dist(coords)) ) coords_new <- rbind(c(500, 500), c(250, 750)) inputs <- make_prediction_inputs(coords = coords, coords_new = coords_new) X_new <- cbind("(Intercept)" = 1, x = c(-0.5, 0.5)) predictions <- predict( fit, X = X_new, Ds_new = inputs$Ds_new, Vs_new = inputs$Vs_new ) predictions$Y_pred# Fit a small spatial model, then predict at two new locations. cells <- expand.grid(spatial = seq_len(4), replicate = seq_len(12)) Vs <- diag(4)[cells$spatial, -1, drop = FALSE] y <- c( 0, 0, 0, 0, 15, 1, 0, 0, 6, 0, 0, 0, 1, 6, 0, 0, 0, 0, 0, 1, 11, 0, 0, 0, 2, 0, 0, 0, 8, 0, 5, 0, 0, 4, 0, 0, 34, 0, 1, 0, 0, 2, 0, 1, 0, 0, 0, 3 ) X <- cbind("(Intercept)" = 1, x = as.numeric(scale(seq_along(y)))) coords <- rbind(c(0, 0), c(1000, 0), c(0, 1000), c(1000, 1000)) set.seed(1) fit <- ZINB_GP( X = X, y = y, coords = coords, nsim = 5, burn = 1, thin = 2, use_count_gp = TRUE, use_inflation_gp = FALSE, Vs = Vs, Ds = as.matrix(stats::dist(coords)) ) coords_new <- rbind(c(500, 500), c(250, 750)) inputs <- make_prediction_inputs(coords = coords, coords_new = coords_new) X_new <- cbind("(Intercept)" = 1, x = c(-0.5, 0.5)) predictions <- predict( fit, X = X_new, Ds_new = inputs$Ds_new, Vs_new = inputs$Vs_new ) predictions$Y_pred
Computes the inverse-logit transformation while clipping its output away from zero and one.
sigmoid(eta)sigmoid(eta)
eta |
Numeric vector or matrix of linear predictors. |
eta transformed to probabilities in [1e-6, 1 - 1e-6].
Use SVD to solve a linear system Ax=b
solve_svd(A_svd, b, threshold = 1e-12)solve_svd(A_svd, b, threshold = 1e-12)
A_svd |
SVD of A |
b |
Right-hand-side vector or matrix. |
threshold |
Singular values at or below this threshold are discarded. |
The SVD-based solution to A %*% x = b.
Update kernel parameters for a GP
update_ls_sigma_noise( ls, sigma, noise_ratio, gpdraw, K, D, lsPrior, sigmaPrior, noisePrior, kern )update_ls_sigma_noise( ls, sigma, noise_ratio, gpdraw, K, D, lsPrior, sigmaPrior, noisePrior, kern )
ls |
Current length scale |
sigma |
Current sigma |
noise_ratio |
Current noise ratio |
gpdraw |
Last draw from the gp with these parameters |
K |
Current kernel matrix |
D |
Distance matrix |
lsPrior |
prior information for length scale, needs mh_sd, max, a, b |
sigmaPrior |
prior information for sigma, needs a, b |
noisePrior |
prior information for noise_ratio, needs mh_sd, a, b |
kern |
Kernel function accepting a distance matrix and a length scale. |
A list with the following elements:
Updated length scale.
Updated GP scale.
Updated kernel-to-noise mixing ratio.
Updated kernel matrix.
Inverse of the updated kernel matrix.
Fits the zero-inflated negative-binomial Gaussian-process model described in doi:10.1016/j.jspi.2023.106098. The supplied spatial and temporal design and distance matrices determine which Gaussian processes are included.
ZINB_GP( X, y, coords, nsim = 5000, burn = 1000, use_count_gp = TRUE, use_inflation_gp = FALSE, thin = 1, kern = NULL, save_ypred = FALSE, print_iter = 100, print_progress = FALSE, Vs = NULL, Vt = NULL, Ds = NULL, Dt = NULL, ltPrior = NULL, lsPrior = NULL, sigmaPrior = NULL, noisePrior = NULL, mh_sd_r = NULL )ZINB_GP( X, y, coords, nsim = 5000, burn = 1000, use_count_gp = TRUE, use_inflation_gp = FALSE, thin = 1, kern = NULL, save_ypred = FALSE, print_iter = 100, print_progress = FALSE, Vs = NULL, Vt = NULL, Ds = NULL, Dt = NULL, ltPrior = NULL, lsPrior = NULL, sigmaPrior = NULL, noisePrior = NULL, mh_sd_r = NULL )
X |
Fixed-effect design matrix with one row per observation. |
y |
Non-negative integer count response. |
coords |
Spatial coordinate matrix with one row per full spatial level,
including the baseline level omitted from |
nsim |
Total number of MCMC iterations; must exceed |
burn |
Number of burn-in iterations. |
use_count_gp |
Whether to include GP random effects in the count component. |
use_inflation_gp |
Whether to include GP random effects in the zero-inflation component. |
thin |
Store every |
kern |
Kernel function accepting a distance matrix and length scale. |
save_ypred |
Whether to save posterior predictive draws. |
print_iter |
Report progress every |
print_progress |
Whether to report MCMC progress via |
Vs |
Spatial random-effect design matrix with one row per observation and the baseline spatial column omitted. |
Vt |
Temporal random-effect design matrix with one row per observation and the baseline temporal column omitted. |
Ds |
Spatial distance matrix for all spatial levels, including the baseline; its diagonal must be zero. |
Dt |
Temporal distance matrix for all temporal levels, including the baseline; its diagonal must be zero. |
ltPrior |
List with |
lsPrior |
List with |
sigmaPrior |
List with |
noisePrior |
List with |
mh_sd_r |
Proposal standard deviation for the negative-binomial dispersion parameter. |
At least one spatial or temporal GP must be active in the count or zero-inflation component. Models with no active GP are outside this entry point and signal an error that points to standard GLM software instead.
A list containing posterior MCMC draws:
Fixed-effect coefficients for the zero-inflation component.
Fixed-effect coefficients for the count component.
Spatial and temporal random effects for the zero-inflation component.
Spatial and temporal random effects for the count component.
Temporal GP length scales for the zero-inflation and count components.
Temporal GP scale parameters.
Spatial GP length scales for the zero-inflation and count components.
Spatial GP scale parameters.
Negative-binomial dispersion parameter.
Latent at-risk indicator draws, included when save_ypred is TRUE.
Posterior predictive count draws, included when save_ypred is TRUE.
# A small synthetic spatial example. cells <- expand.grid(spatial = seq_len(4), replicate = seq_len(12)) Vs <- diag(4)[cells$spatial, -1, drop = FALSE] y <- c( 0, 0, 0, 0, 15, 1, 0, 0, 6, 0, 0, 0, 1, 6, 0, 0, 0, 0, 0, 1, 11, 0, 0, 0, 2, 0, 0, 0, 8, 0, 5, 0, 0, 4, 0, 0, 34, 0, 1, 0, 0, 2, 0, 1, 0, 0, 0, 3 ) X <- cbind("(Intercept)" = 1, x = as.numeric(scale(seq_along(y)))) coords <- rbind(c(0, 0), c(1000, 0), c(0, 1000), c(1000, 1000)) set.seed(1) fit <- ZINB_GP( X = X, y = y, coords = coords, nsim = 5, burn = 1, thin = 2, use_count_gp = TRUE, use_inflation_gp = FALSE, Vs = Vs, Ds = as.matrix(stats::dist(coords)) ) names(fit)# A small synthetic spatial example. cells <- expand.grid(spatial = seq_len(4), replicate = seq_len(12)) Vs <- diag(4)[cells$spatial, -1, drop = FALSE] y <- c( 0, 0, 0, 0, 15, 1, 0, 0, 6, 0, 0, 0, 1, 6, 0, 0, 0, 0, 0, 1, 11, 0, 0, 0, 2, 0, 0, 0, 8, 0, 5, 0, 0, 4, 0, 0, 34, 0, 1, 0, 0, 2, 0, 1, 0, 0, 0, 3 ) X <- cbind("(Intercept)" = 1, x = as.numeric(scale(seq_along(y)))) coords <- rbind(c(0, 0), c(1000, 0), c(0, 1000), c(1000, 1000)) set.seed(1) fit <- ZINB_GP( X = X, y = y, coords = coords, nsim = 5, burn = 1, thin = 2, use_count_gp = TRUE, use_inflation_gp = FALSE, Vs = Vs, Ds = as.matrix(stats::dist(coords)) ) names(fit)
Run the ZINB GP model with GP random effects only in the count part.
ZINB_GP_count( X, y, coords, Vs, Vt, Ds, Dt, nsim, burn, thin = 1, save_ypred = FALSE, print_iter = 100, print_progress = FALSE, ltPrior = NULL, lsPrior = NULL, sigmaPrior = NULL, noisePrior = NULL, mh_sd_r = NULL, kern = NULL )ZINB_GP_count( X, y, coords, Vs, Vt, Ds, Dt, nsim, burn, thin = 1, save_ypred = FALSE, print_iter = 100, print_progress = FALSE, ltPrior = NULL, lsPrior = NULL, sigmaPrior = NULL, noisePrior = NULL, mh_sd_r = NULL, kern = NULL )
X |
Fixed-effect design matrix with one row per observation. |
y |
Non-negative integer count response. |
coords |
Spatial coordinate matrix with one row per full spatial level,
including the baseline level omitted from |
Vs |
Spatial random-effect design matrix with one row per observation. |
Vt |
Temporal random-effect design matrix with one row per observation. |
Ds |
Spatial distance matrix; its diagonal must be zero. |
Dt |
Temporal distance matrix; its diagonal must be zero. |
nsim |
Total number of MCMC iterations; must exceed |
burn |
Number of burn-in iterations. |
thin |
Store every |
save_ypred |
Whether to save posterior predictive draws. |
print_iter |
Print progress every |
print_progress |
Whether to print MCMC progress. |
ltPrior |
List with |
lsPrior |
List with |
sigmaPrior |
List with |
noisePrior |
List with |
mh_sd_r |
Proposal standard deviation for the negative-binomial dispersion parameter. |
kern |
Kernel function accepting a distance matrix and length scale. |
A list containing posterior MCMC draws for the count GP, fixed effects, and the negative-binomial dispersion parameter.
Run the ZINB GP model with GP random effects only in the inflation component
ZINB_GP_inflation( X, y, coords, Vs, Vt, Ds, Dt, nsim, burn, thin = 1, save_ypred = FALSE, print_iter = 100, print_progress = FALSE, ltPrior = NULL, lsPrior = NULL, sigmaPrior = NULL, noisePrior = NULL, mh_sd_r = NULL, kern = NULL )ZINB_GP_inflation( X, y, coords, Vs, Vt, Ds, Dt, nsim, burn, thin = 1, save_ypred = FALSE, print_iter = 100, print_progress = FALSE, ltPrior = NULL, lsPrior = NULL, sigmaPrior = NULL, noisePrior = NULL, mh_sd_r = NULL, kern = NULL )
X |
Fixed-effect design matrix with one row per observation. |
y |
Non-negative integer count response. |
coords |
Spatial coordinate matrix with one row per full spatial level,
including the baseline level omitted from |
Vs |
Spatial random-effect design matrix with one row per observation. |
Vt |
Temporal random-effect design matrix with one row per observation. |
Ds |
Spatial distance matrix; its diagonal must be zero. |
Dt |
Temporal distance matrix; its diagonal must be zero. |
nsim |
Total number of MCMC iterations; must exceed |
burn |
Number of burn-in iterations. |
thin |
Store every |
save_ypred |
Whether to save posterior predictive draws. |
print_iter |
Print progress every |
print_progress |
Whether to print MCMC progress. |
ltPrior |
List with |
lsPrior |
List with |
sigmaPrior |
List with |
noisePrior |
List with |
mh_sd_r |
Proposal standard deviation for the negative-binomial dispersion parameter. |
kern |
Kernel function accepting a distance matrix and length scale. |
A list containing posterior MCMC draws for the zero-inflation GP, fixed effects, and the negative-binomial dispersion parameter.
Fits the spatial-temporal zero-inflated negative-binomial Gaussian-process model described in doi:10.1016/j.jspi.2023.106098.
ZINB_GP_orig( X, y, coords, Vs, Vt, Ds, Dt, nsim, burn, thin = 1, save_ypred = FALSE, print_iter = 100, print_progress = FALSE, ltPrior = NULL, lsPrior = NULL, sigmaPrior = NULL, noisePrior = NULL, mh_sd_r = NULL, kern = NULL )ZINB_GP_orig( X, y, coords, Vs, Vt, Ds, Dt, nsim, burn, thin = 1, save_ypred = FALSE, print_iter = 100, print_progress = FALSE, ltPrior = NULL, lsPrior = NULL, sigmaPrior = NULL, noisePrior = NULL, mh_sd_r = NULL, kern = NULL )
X |
Fixed-effect design matrix with one row per observation. |
y |
Non-negative integer count response. |
coords |
Spatial coordinate matrix with one row per full spatial level,
including the baseline level omitted from |
Vs |
Spatial random-effect design matrix with one row per observation. |
Vt |
Temporal random-effect design matrix with one row per observation. |
Ds |
Spatial distance matrix; its diagonal must be zero. |
Dt |
Temporal distance matrix; its diagonal must be zero. |
nsim |
Total number of MCMC iterations; must exceed |
burn |
Number of burn-in iterations. |
thin |
Store every |
save_ypred |
Whether to save posterior predictive draws. |
print_iter |
Print progress every |
print_progress |
Whether to print MCMC progress. |
ltPrior |
List with |
lsPrior |
List with |
sigmaPrior |
List with |
noisePrior |
List with |
mh_sd_r |
Proposal standard deviation for the negative-binomial dispersion parameter. |
kern |
Kernel function accepting a distance matrix and length scale. |
A list containing posterior MCMC draws, including fixed-effect coefficients, spatial and temporal random effects, their GP parameters, the negative-binomial dispersion parameter, and optional predictive draws.
Fit a zero-inflated negative-binomial model with spatial Gaussian-process random effects in both the zero-inflation and count components.
ZINB_GP_spatial( X, y, Vs, Ds, nsim, burn, thin = 1, save_ypred = FALSE, print_iter = 100, print_progress = FALSE, lsPrior = NULL, sigmaPrior = NULL, noisePrior = NULL, mh_sd_r = NULL, kern = NULL )ZINB_GP_spatial( X, y, Vs, Ds, nsim, burn, thin = 1, save_ypred = FALSE, print_iter = 100, print_progress = FALSE, lsPrior = NULL, sigmaPrior = NULL, noisePrior = NULL, mh_sd_r = NULL, kern = NULL )
X |
Fixed-effect design matrix with N rows. |
y |
Non-negative integer count response of length N. |
Vs |
Sparse or dense spatial random-effect design matrix. It should have N rows and one column per spatial location. |
Ds |
Spatial distance matrix with one row and column per full spatial
level, including the baseline level omitted from |
nsim |
Total number of MCMC iterations. |
burn |
Number of burn-in iterations. |
thin |
Store every thin-th iteration after burn-in. |
save_ypred |
Whether to save posterior predictive counts and at-risk draws. |
print_iter |
Print progress every print_iter iterations. |
print_progress |
Whether to print MCMC progress. |
lsPrior |
Prior and proposal controls for spatial GP length scales. |
sigmaPrior |
Inverse-gamma prior parameters for GP variances. |
noisePrior |
Beta prior and MH controls for GP noise ratios. |
mh_sd_r |
Proposal standard deviation for NB dispersion r. |
kern |
Kernel function accepting a squared-distance matrix and a length scale. |
A list containing posterior MCMC draws.
Fit a zero-inflated negative-binomial model with spatial Gaussian-process random effects in only the count component.
ZINB_GP_spatial_count( X, y, Vs, Ds, nsim, burn, thin = 1, save_ypred = FALSE, print_iter = 100, print_progress = FALSE, lsPrior = NULL, sigmaPrior = NULL, noisePrior = NULL, mh_sd_r = NULL, kern = NULL )ZINB_GP_spatial_count( X, y, Vs, Ds, nsim, burn, thin = 1, save_ypred = FALSE, print_iter = 100, print_progress = FALSE, lsPrior = NULL, sigmaPrior = NULL, noisePrior = NULL, mh_sd_r = NULL, kern = NULL )
X |
Fixed-effect design matrix with N rows. |
y |
Non-negative integer count response of length N. |
Vs |
Sparse or dense spatial random-effect design matrix. It should have N rows and one column per spatial location. |
Ds |
Spatial distance matrix with one row and column per full spatial
level, including the baseline level omitted from |
nsim |
Total number of MCMC iterations. |
burn |
Number of burn-in iterations. |
thin |
Store every thin-th iteration after burn-in. |
save_ypred |
Whether to save posterior predictive counts and at-risk draws. |
print_iter |
Print progress every print_iter iterations. |
print_progress |
Whether to print MCMC progress. |
lsPrior |
Prior and proposal controls for spatial GP length scales. |
sigmaPrior |
Inverse-gamma prior parameters for GP variances. |
noisePrior |
Beta prior and MH controls for GP noise ratios. |
mh_sd_r |
Proposal standard deviation for NB dispersion r. |
kern |
Kernel function accepting a squared-distance matrix and a length scale. |
A list containing posterior MCMC draws.
Fit a zero-inflated negative-binomial model with spatial Gaussian-process random effects in only the inflation part.
ZINB_GP_spatial_inflation( X, y, Vs, Ds, nsim, burn, thin = 1, save_ypred = FALSE, print_iter = 100, print_progress = FALSE, lsPrior = NULL, sigmaPrior = NULL, noisePrior = NULL, mh_sd_r = NULL, kern = NULL )ZINB_GP_spatial_inflation( X, y, Vs, Ds, nsim, burn, thin = 1, save_ypred = FALSE, print_iter = 100, print_progress = FALSE, lsPrior = NULL, sigmaPrior = NULL, noisePrior = NULL, mh_sd_r = NULL, kern = NULL )
X |
Fixed-effect design matrix with N rows. |
y |
Non-negative integer count response of length N. |
Vs |
Sparse or dense spatial random-effect design matrix. It should have N rows and one column per spatial location. |
Ds |
Spatial distance matrix with one row and column per full spatial
level, including the baseline level omitted from |
nsim |
Total number of MCMC iterations. |
burn |
Number of burn-in iterations. |
thin |
Store every thin-th iteration after burn-in. |
save_ypred |
Whether to save posterior predictive counts and at-risk draws. |
print_iter |
Print progress every print_iter iterations. |
print_progress |
Whether to print MCMC progress. |
lsPrior |
Prior and proposal controls for spatial GP length scales. |
sigmaPrior |
Inverse-gamma prior parameters for GP variances. |
noisePrior |
Beta prior and MH controls for GP noise ratios. |
mh_sd_r |
Proposal standard deviation for NB dispersion r. |
kern |
Kernel function accepting a squared-distance matrix and a length scale. |
A list containing posterior MCMC draws.