plausibility: calculate plausibility of 'Y(s0)' being 'Y0'

View source: R/plausibility.R

plausibilityR Documentation

calculate plausibility of Y(s0) being Y0

Description

This function provides the plausibility of Y(s0) being Y0, given observations s and Y, using spatial conformal prediction algorithms.

Usage

plausibility(
  Y0,
  s0,
  s,
  Y,
  global = TRUE,
  eta = Inf,
  m = NULL,
  pred_fun = krige_pred,
  thetaHat = NULL,
  dfun = c("residual2", "std_residual2")
)

Arguments

Y0

a scalar or a vector

s0

prediction location, a numeric vector with length = 2 or a matrix with 1 row and 2 cols, or a data.frame with 1 row and 2 cordinates.

s

an n x 2 matrix or a data.frame with two coordinates of n locations.

Y

a vector with n values corresponding to Y(s).

global

logical; if TRUE , scp function returns the result of global spatial conformal prediction (GSCP); if FALSE, scp function returns the result of local spatial conformal prediction (LSCP) and users need to specify eta < Inf or m ≤q n. Defaults to TRUE.

eta

kernel bandwidth for weight schema, a positve scalar with smaller value meaning more localized procedure. Defauls to Inf, which puts equal weight on surrounding m points.

m

an postive integer representing the number of nearest locations to use for prediction. Default to NULL. If global = TRUE, m = n; if global = FALSE and m is not specified, m would be determined by eta.

pred_fun

spatial prediction function with inputs being s0, s, Y and ouputs being predicted Y(s0) (and its standard error). Defaults to krige_pred.

thetaHat

a vector of Matern parameters, representing nugget, partial sill, range, and smoothness as in Mao. et al. (2020). Defaults to NULL. It will be ignored if pred_fun is not krige_pred.

dfun

non-conformity measure with four options. In which, "residual2" (default) represents squared residual and "std_residual2" represents standardized squared residual.

Value

The output is a scalar or a vector with plausibility values for Y0. The numbers are between 0 and 1.

Author(s)

Huiying Mao, hmao@samsi.info, Brian Reich bjreich@ncsu.edu

References

to be entered

See Also

plausibility_contour

Examples

## To predict Y(s0), where s0 = c(0.5,0.5), using sample data
## What's the plausibility if Y(s0) = 0? Y(s0) = 1.5?

#?sample_data
s0 = c(0.5,0.5)
s  = sample_data$s
Y  = sample_data$Y

# plausibility for Y(s0) = 0
plausibility(Y0=0,s0=s0,s=s,Y=Y)

# plausibility for Y(s0) = 1.5
plausibility(Y0=1.5,s0=s0,s=s,Y=Y)

# plausibility for a sequence of Y0's
plausibility(Y0=seq(0,1,0.1),s0=s0,s=s,Y=Y)


mhuiying/scp documentation built on May 4, 2022, 11:35 p.m.