integrationWeights: Functions to compute integration weights

Description Usage Arguments Details See Also Examples

View source: R/baselearners.R

Description

Computes trapezoidal integration weights (Riemann sums) for a functional variable X1 that has evaluation points xind.

Usage

1
2
3
integrationWeights(X1, xind, id = NULL)

integrationWeightsLeft(X1, xind, leftWeight = c("first", "mean", "zero"))

Arguments

X1

for functional data that is observed on one common grid, a matrix containing the observations of the functional variable. For a functional variable that is observed on curve specific grids, a long vector.

xind

evaluation points (index) of functional variable

id

defaults to NULL. Only necessary for response in long format. In this case id specifies which curves belong together.

leftWeight

one of c("mean", "first", "zero"). With left Riemann sums different assumptions for the weight of the first observation are possible. The default is to use the mean over all integration weights, "mean". Alternatively one can use the first integration weight, "first", or use the distance to zero, "zero".

Details

The function integrationWeights() computes trapezoidal integration weights, that are symmetric. Per default those weights are used in the bsignal-base-learner. In the special case of evaluation points (xind) with equal distances, all integration weights are equal.

The function integrationWeightsLeft() computes weights, that take into account only the distance to the prior observation point. Thus one has to decide what to do with the first observation. The left weights are adequate for historical effects like in bhist.

See Also

bsignal and bhist for the base-learners.

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
32
33
34
## Example for trapezoidal integration weights
xind0 <- seq(0,1,l = 5)
xind <- c(0, 0.1, 0.3, 0.7, 1)
X1 <- matrix(xind^2, ncol = length(xind0), nrow = 2)

# Regualar observation points
integrationWeights(X1, xind0)
# Irregular observation points
integrationWeights(X1, xind)

# with missing value
X1[1,2] <- NA
integrationWeights(X1, xind0)
integrationWeights(X1, xind)

## Example for left integration weights
xind0 <- seq(0,1,l = 5)
xind <- c(0, 0.1, 0.3, 0.7, 1)
X1 <- matrix(xind^2, ncol = length(xind0), nrow = 2)

# Regular observation points
integrationWeightsLeft(X1, xind0, leftWeight = "mean") 
integrationWeightsLeft(X1, xind0, leftWeight = "first") 
integrationWeightsLeft(X1, xind0, leftWeight = "zero")

# Irregular observation points
integrationWeightsLeft(X1, xind, leftWeight = "mean") 
integrationWeightsLeft(X1, xind, leftWeight = "first") 
integrationWeightsLeft(X1, xind, leftWeight = "zero")

# obervation points that do not start with 0
xind2 <- xind + 0.5
integrationWeightsLeft(X1, xind2, leftWeight = "zero")
 

FDboost documentation built on May 31, 2017, 8:26 p.m.