Learn R Programming

vdg (version 1.1.3)

spv: Calculate the Scaled Prediction Variance (or SPV)

Description

Calculates the SPV for a sample of points in a design region of specified type. Sampling is done by calling sampler.

Usage

spv(n, design, type = "spherical", formula, at = FALSE, keepfun, sample, unscaled = FALSE, ...)
"spv"(n, design, type = c("spherical", "cuboidal", "lhs", "mlhs", "slhs", "rslhs", "custom"), formula, at = FALSE, keepfun, sample, unscaled = FALSE, ...)
"spv"(n, design, type = c("spherical", "cuboidal", "lhs", "mlhs", "slhs", "rslhs", "custom"), formula, at = FALSE, keepfun, sample, unscaled = FALSE, ...)
"spv"(n, design, type = c("spherical", "cuboidal", "lhs", "mlhs", "slhs", "rslhs", "custom"), formula, at = FALSE, keepfun, sample, unscaled = FALSE, ...)

Arguments

n
number of samples to take
design
a design or list of designs. Each design must be either a matrix or a data.frame or coercible to a data.frame.
type
type of sampling passed to sampler
formula
either a single model formula of a list of formulae
at
only used when type is 'spherical' or 'cuboidal'
keepfun
optional; function operating on the columns of a matrix with the same number of columns as design which return a logical value for including a specific point in the sample or not. Useful for rejection sampling for nonstandard design regions.
sample
optional; if not missing it should contain a matrix or data.frame containing points sampled over the required design region. If it is not missing, no further sampling will be done: the SPV is simply evaluated at these points.
unscaled
logical indicating whether to use the unscaled prediction variance (UPV) instead of the scale prediction variance (SPV)
...
additional arguments passed to sampler. This enables the used of user-specified sampling functions via the custom.fun argument to sampler.

Value

Object of class 'spv', 'spvlist', 'spvforlist' or 'spvlistforlist', depending on whether single designs/formulas are passed or lists of these.

See Also

plot.spv for more examples

Examples

Run this code

# Single design (class 'spv')
library(rsm)
bbd3 <- as.data.frame(bbd(3)[,3:5])
colnames(bbd3) <- paste0("x", 1:3)
quad.3f <- formula(~(x1 + x2 + x3)^2 - x1:x2:x3)
out <- spv(n = 1000, design = bbd3, type = "spherical", formula = quad.3f)
out

Run the code above in your browser using DataLab