ffpc: Construct a PC-based function-on-function regression term

Description Usage Arguments Details Value Author(s) Examples

View source: R/pffr-ffpc.R

Description

Defines a term \int X_i(s)β(t,s)ds for inclusion in an mgcv::gam-formula (or bam or gamm or gamm4:::gamm4) as constructed by pffr.

Usage

1
2
3
4
5
6
7
8
ffpc(
  X,
  yind = NULL,
  xind = seq(0, 1, length = ncol(X)),
  splinepars = list(bs = "ps", m = c(2, 1), k = 8),
  decomppars = list(pve = 0.99, useSymm = TRUE),
  npc.max = 15
)

Arguments

X

an n by ncol(xind) matrix of function evaluations X_i(s_{i1}),…, X_i(s_{iS}); i=1,…,n.

yind

DEPRECATED used to supply matrix (or vector) of indices of evaluations of Y_i(t), no longer used.

xind

matrix (or vector) of indices of evaluations of X_i(t), defaults to seq(0, 1, length=ncol(X)).

splinepars

optional arguments supplied to the basistype-term. Defaults to a cubic B-spline with first difference penalties and 8 basis functions for each \tilde β_k(t).

decomppars

parameters for the FPCA performed with fpca.sc.

npc.max

maximal number K of FPCs to use, regardless of decomppars; defaults to 15

Details

In contrast to ff, ffpc does an FPCA decomposition X(s) \approx ∑^K_{k=1} ξ_{ik} Φ_k(s) using fpca.sc and represents β(t,s) in the function space spanned by these Φ_k(s). That is, since

\int X_i(s)β(t,s)ds = ∑^K_{k=1} ξ_{ik} \int Φ_k(s) β(s,t) ds = ∑^K_{k=1} ξ_{ik} \tilde β_k(t),

the function-on-function term can be represented as a sum of K univariate functions \tilde β_k(t) in t each multiplied by the FPC scores ξ_{ik}. The truncation parameter K is chosen as described in fpca.sc. Using this instead of ff() can be beneficial if the covariance operator of the X_i(s) has low effective rank (i.e., if K is small). If the covariance operator of the X_i(s) is of (very) high rank, i.e., if K is large, ffpc() will not be very efficient.

To reduce model complexity, the \tilde β_k(t) all have a single joint smoothing parameter (in mgcv, they get the same id, see s).

Please see pffr for details on model specification and implementation.

Value

A list containing the necessary information to construct a term to be included in a mgcv::gam-formula.

Author(s)

Fabian Scheipl

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
35
36
37
38
39
40
41
42
43
44
45
## Not run: 
set.seed(1122)
n <- 55
S <- 60
T <- 50
s <- seq(0,1, l=S)
t <- seq(0,1, l=T)

#generate X from a polynomial FPC-basis:
rankX <- 5
Phi <- cbind(1/sqrt(S), poly(s, degree=rankX-1))
lambda <- rankX:1
Xi <- sapply(lambda, function(l)
            scale(rnorm(n, sd=sqrt(l)), scale=FALSE))
X <- Xi %*% t(Phi)

beta.st <- outer(s, t, function(s, t) cos(2 * pi * s * t))

y <- (1/S*X) %*% beta.st + 0.1 * matrix(rnorm(n * T), nrow=n, ncol=T)

data <- list(y=y, X=X)
# set number of FPCs to true rank of process for this example:
m.pc <- pffr(y ~ c(1) + 0 + ffpc(X, yind=t, decomppars=list(npc=rankX)),
        data=data, yind=t)
summary(m.pc)
m.ff <- pffr(y ~ c(1) + 0 + ff(X, yind=t), data=data, yind=t)
summary(m.ff)

# fits are very similar:
all.equal(fitted(m.pc), fitted(m.ff))

# plot implied coefficient surfaces:
layout(t(1:3))
persp(t, s, t(beta.st), theta=50, phi=40, main="Truth",
    ticktype="detailed")
plot(m.ff, select=1, pers=TRUE, zlim=range(beta.st), theta=50, phi=40,
    ticktype="detailed")
title(main="ff()")
ffpcplot(m.pc, type="surf", auto.layout=FALSE, theta = 50, phi = 40)
title(main="ffpc()")

# show default ffpcplot:
ffpcplot(m.pc)

## End(Not run)

refund documentation built on July 1, 2021, 9:06 a.m.