Description Usage Arguments Value Note Author(s) See Also Examples
Computes the gradient of the vector of trend basis functions f(x)=(f1(x);...;fp(x))
1 | trend.deltax(x, model, h = sqrt(.Machine$double.eps))
|
x |
a vector representing the specific location. |
model |
an object of class km. |
h |
the precision for numerical derivatives. |
A pxd
matrix where the p
rows contain the gradient of the trend basis functions.
The gradient is computed analytically in 4 common practical situations: formula=~1
(constant trend), formula=~.
(first-order polynomial), formula=~.^2
(first-order polynomial + second-order interactions), first-order polynomial + (pure) quadratic terms. In the other cases, the gradient is approximated by a finite difference of the form (g(x+h)-g(x-h))/2h
, where h
is tunable.
O. Roustant, Ecole des Mines de St-Etienne.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | X <- expand.grid(x1=seq(0,1,length=4), x2=seq(0,1,length=4), x3=seq(0,1,length=4))
fun <- function(x){
(x[1]+2*x[2]+3*x[3])^2
}
y <- apply(X, 1, fun)
x <- c(0.2, 0.4, 0.6)
coef.cov=c(0.5, 0.9, 1.3); coef.var=3
m <- km(~.^2, design=X, response=y, coef.cov=coef.cov, coef.var=coef.var)
grad.trend <- trend.deltax(x, m)
print(grad.trend)
m <- km(~. + I(x1^2) + I(x2^2) + I(x3^2),
design=X, response=y, coef.cov=coef.cov, coef.var=coef.var)
grad.trend <- trend.deltax(x, m)
print(grad.trend)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.