scp: Spatial conformal prediction at input location(s)

View source: R/scp.R

scpR Documentation

Spatial conformal prediction at input location(s)

Description

This function provides the spatial conformal prediction interval for location(s) s0, given obserations s and Y.

Usage

scp(
  s0,
  s,
  Y,
  global = TRUE,
  eta = Inf,
  m = NULL,
  pred_fun = krige_pred,
  thetaHat = NULL,
  dfun = c("residual2", "std_residual2"),
  precision = NULL,
  alpha = 0.05
)

Arguments

s0

prediction location(s), a numeric vector with length = 2, or a matrix with ncol = 2, or a data.frame with two coordinates.

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. 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 depands on 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 representing Kriging prediction.

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.

precision

a positive scalar represents how dense the candidates for Y(s) are. Defaults to NULL.

alpha

significance level. Defaults to 0.05.

Value

The output is a data.frame of lower and upper bounds of the conformal prediction interval(s) for s0.

Author(s)

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

References

to be entered

See Also

plausibility, plausibility_contour

Examples

## generate prediction interval for prediction locations(s) s0(s) using sample data

#?sample_data
s  = sample_data$s
Y  = sample_data$Y

# locations to predict
s0  = c(0.5,0.5)
s0s = rbind(c(0.4, 0.4), c(0.5,0.5), c(0.6, 0.6))

# default prediction interval
scp(s0=s0,s=s,Y=Y)
scp(s0=s0s,s=s,Y=Y)

# user define eta=0.1, where LSCP is considered
scp(s0=s0,s=s,Y=Y,eta=0.1)

# user define non-conformity measure
scp(s0=s0,s=s,Y=Y,dfun="std_residual2")

# user define prediction function
fun = function(s0,s,Y) return(mean(Y))
scp(s0=s0,s=s,Y=Y,pred_fun=fun)

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