makeQuantileSimulationSurface: Create quantile-simulation surfaces

View source: R/makeQuantileSimulationSurface.R

makeQuantileSimulationSurfaceR Documentation

Create quantile-simulation surfaces

Description

Converts normalized probability surfaces (e.g. one layer output of isotopeAssignmentModel function) to quantile surfaces.

Usage

makeQuantileSimulationSurface(
  probabilitySurface,
  ValidationQuantiles,
  rename = FALSE,
  rescale = TRUE
)

Arguments

probabilitySurface

Normalized probability surface RasterLayer.

ValidationQuantiles

Vector of quantile values from known-origin individuals, against which to compare each value within the probability surface. Each value must be between 0 and 1.

rename

Character value to append to raster name (e.g. "_quantileSimulation"). Defaults to FALSE.

rescale

If rescale = TRUE, returns surface showing proportion of times each surface cell value fell within the validation quantiles distribution. If rescale = FALSE, returns discrete number of times the cell fell within the distribution.

Value

Returns RasterLayer rescaled to quantile values.

Examples

# Generate example probability surfaces.
library(isocat)
myiso <- raster::rasterFromXYZ(isoscape)
myiso_sd <- raster::rasterFromXYZ(isoscape_sd)
df <- data.frame(
         ID = c(-100, -80, -50),
         isotopeValue = c(-100, -80, -50),
         SD_indv = rep(5, 3)
         )
assignmentModels <- isotopeAssignmentModel(
         ID = df$ID,
         isotopeValue = df$isotopeValue,
         SD_indv = df$SD_indv,
         precip_raster = myiso,
         precip_SD_raster = myiso_sd
         )

# Example known-origin quantile data.
q <- rweibull(20000, 6, .98)
q <- sample( q[ q >=0 & q <= 1 ], 10000, replace = TRUE)
hist(q)

# Convert to quantile surfaces.
quantileSimulation_surface <-  raster::stack(
                  lapply(
                            unstack(assignmentModels),
                            makeQuantileSimulationSurface,
                            ValidationQuantiles = q)
                        )
plot(quantileSimulation_surface)


cjcampbell/IsoModAT documentation built on Feb. 21, 2024, 10:27 a.m.