Creates a likelihood surface representing the relative intensity of values compared to what would be expected under a reference distribution. This is useful for Bayesian updating of spatial probability distributions.
The likelihood surface shows where values are higher or lower than expected: - Values > 1 indicate higher than expected - Values = 1 indicate as expected - Values < 1 indicate lower than expected
Usage
transform_likelihood(
x,
value_col = NULL,
template = NULL,
method = "mean",
ref_value = NULL,
standardize = FALSE,
snap = FALSE
)Arguments
- x
SpatRaster or SpatVector containing observed values
- value_col
Character; name of column if x is SpatVector
- template
SpatRaster; template for rasterization if x is SpatVector
- method
Character; method to compute reference value: - "mean": Compare to mean value (default) - "sum": Compare to sum - "custom": Compare to provided ref_value
- ref_value
Numeric; custom reference value if method = "custom"
- standardize
Logical; if TRUE return z-scores instead of ratios
- snap
Logical; if TRUE skip validation
Examples
if (FALSE) { # \dontrun{
# From raster input
pop <- rast(u5pd)
lik1 <- transform_likelihood(pop)
# From vector input
lik2 <- transform_likelihood(
case_spatial,
value_col = "cases",
template = pop
)
# With custom reference
lik3 <- transform_likelihood(
pop,
method = "custom",
ref_value = 100
)
} # }