Integrate: Defined integral of GeDS objects

Description Usage Arguments Details References Examples

View source: R/IntegrateDerive.R

Description

This function computes defined integrals of a fitted GeDS regression model.

Usage

1
Integrate(object, to, from, n = 3L)

Arguments

object

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

to

numeric vector containing the upper limit(s) of integration.

from

optional numeric vector containing the lower limit(s) of integration. It should be either of size one or of the same size as the argument to. If left unspecified, by default it is set to the left-most limit of the interval embedding the observations of the independent variable.

n

integer value (2, 3 or 4) specifying the order (= degree + 1) of the GeDS fit to be integrated. By default equal to 3L. Non-integer values will be passed to the function as.integer.

Details

The function is based on the well known property (c.f. De Boor, 2001, Chapter X, formula (33)) that the integral of a linear combination of appropriately normalized B-splines is equal to the sum of its corresponding coefficients, noting that the GeDS regression is in fact such a linear combination.

Since the function is based on this property, it is designed to work only on the predictor scale in the GNM (GLM) framework.

If the argument from is a single value, then it is taken as the lower limit of integration for all the defined integrals required, whereas the upper limits of integration are the values contained in the argument to. If the arguments from and to are of similar size, the integrals (as many as the size) are computed by sequentially taking the pairs of values in the from and to vectors as limits of integration.

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
19
20
21
22
23
24
25
26
27
28
29
30
31
# Generate a data sample for the response variable
# Y and the single covariate X
# see Dimitrova et al. (2017), section 4.1
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 using NGeDS
Gmod <- NGeDS(Y ~ f(X), beta = 0.6, phi = .995, Xextr = c(-2,2))

# Compute defined integrals (in TeX style) $\int_{1}^{-1} f(x)dx$
# and $\int_{1}^{1} f(x)dx$
# $f$ being the quadratic fit
Integrate(Gmod, to = c(-1,1), from = 1, n = 3)

# Compute defined integrals (in TeX style) $\int_{1}^{-1} f(x)dx$
# and $\int_{-1}^{1} f(x)dx$
# $f$ being the quadratic fit
Integrate(Gmod, to = c(-1,1), from = c(1,-1), n = 3)

## Not run: 
## This gives an error
Integrate(Gmod, to = 1, from = c(1,-1), n = 3)

## End(Not run)

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