Integrate {GeDS} | R Documentation |
Defined integral of GeDS objects
Description
This function computes defined integrals of a fitted GeDS regression model.
Usage
Integrate(object, to, from, n = 3L)
Arguments
object |
the |
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 |
n |
integer value (2, 3 or 4) specifying the order ( |
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
# Generate a data sample for the response variable
# Y and the single covariate X
# see Dimitrova et al. (2023), 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)