Derive: Derivative of GeDS objects

Description Usage Arguments Details References Examples

View source: R/IntegrateDerive.R

Description

This function computes derivatives of a fitted GeDS regression model.

Usage

1
Derive(object, order = 1L, x, n = 3L)

Arguments

object

the GeDS-Class object containing the GeDS fit which should be differentiated. It should be the result of fitting a univariate GeDS regression via NGeDS or GGeDS.

order

integer value indicating the order of differentiation required (e.g. first, second or higher derivatives). Note that order should be lower than n and that non-integer values will be passed to the function as.integer.

x

numeric vector containing values of the independent variable at which the derivatives of order order should be computed.

n

integer value (2, 3 or 4) specifying the order (= degree + 1) of the GeDS fit to be differentiated. By default equal to 3L.

Details

The function is based on splineDesign and it computes the exact derivative of the fitted GeDS regression.

The function uses the property that the m-th derivative of a spline, m= 1,2,..., expressed in terms of B-splines can be computed by differencing the corresponding B-spline coefficients (see e.g. De Boor, 2001, Chapter X, formula (15)). Since the GeDS fit is a B-spline representation of the predictor, it cannot work on the response scale in the GNM (GLM) framework.

References

De Boor, C. (2001). A Practical Guide to Splines (Revised Edition). Springer, New York.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
# Generate a data sample for the response variable
# Y and the covariate X
set.seed(123)
N <- 500
f_1 <- function(x) (10*x/(1+100*x^2))*4+4
X <- sort(runif(N, min = -2, max = 2))
# Specify a model for the mean of Y to include only
# a component non-linear in X, defined by the function f_1
means <- f_1(X)
# Add (Normal) noise to the mean of Y
Y <- rnorm(N, means, sd = 0.1)

# Fit GeDS regression with only a spline component in the predictor model
Gmod <- NGeDS(Y ~ f(X), beta = 0.6, phi = 0.995, Xextr = c(-2,2))

# Compute the second derivative of the cubic GeDS fit
# at the points 0, -1 and 1
Derive(Gmod, x = c(0, -1, 1), order = 2, n = 4)

GeDS documentation built on May 2, 2019, 12:36 p.m.