Learn R Programming

eBsc (version 4.17)

drbasis: Computation of the Demmler-Reinsch basis.

Description

The Demmler-Reinsch basis is provided for a given smoothness degree in a uniform grid.

Usage

drbasis(nn,qq)

Value

A list object containing the following information.

eigenvalues

estimadted eigenvalues

eigenvectors

estimated eigenvectors

eigenvectorsQR

orthonormal eigenvectors

x

equidistant grid used to build the basis

Arguments

nn

Number of design points in the uniform grid.

qq

Smoothness degree of the basis.

Author

Francisco Rosales

Details

The use of large numbers required by the basis is handled by the package Brobdingnag. The method assumes the grid is equidistant. Missing values are not supported.

References

Rosales F. (2016).
Empirical Bayesian Smoothing Splines for Signals with Correlated Errors: Methods and Applications

Serra, P. and Krivobokova, T. (2015)
Adaptive Empirical Bayesian Smoothing Splines

Examples

Run this code
oldpar <- par(no.readonly = TRUE)
#plot elements of the basis
library(eBsc)
n <- 100
Basis <- list()
for(i in 1:6){Basis[[i]] <- drbasis( nn = n, qq = i)}

#eigenvalues
par(mfrow = c(3,2), mar = c(4,2,2,2))
for(i in 1:6){
name <- paste("Eigenvalues (q = ",i,")", sep = "")
plot(Basis[[i]]$eigenvalues,
type = 'l', lwd = 2, xlab = "x", ylab = "", main = name)	
}
par(oldpar) 

#eigenvectors for q = 3
par(mfrow = c(3,2), mar = c(4,2,2,2))
for(i in 1:6){
name <- paste("Eigenvector n. ", i + 3, sep = "")
plot(Basis[[i]]$eigenvectorsQR[, i + 3],
type = 'l', lwd = 2, xlab = "x", ylab = "", main = name)	
}
par(oldpar) 

#example of a smooth function in the Demmler-Reinsch basis
library(eBsc)
n <- 200
Basis <- list()
for(i in 1:6){Basis[[i]] <- drbasis(nn = n, qq = i)}
coef3 <- c(rep(0,3), (pi*(2:(n-2))) ^ (-3.1)) * (cos(2*(1:n)))
A3 <- Basis[[3]]$eigenvectors
mu <- -A3%*%coef3
mu <- (mu - min(mu)) / (max(mu) - min(mu))
plot(mu, xlab = "x", ylab = "mu", type = 'l', lwd = 2)
par(oldpar)

Run the code above in your browser using DataLab