NRRR.func: Multivatiate functional regression via nested reduced-rank...

Description Usage Arguments Details Value References Examples

View source: R/NRRR.func.r

Description

This function takes functional observations as input and fits a nested reduced-rank regression with a user-specified rank selection method. The B-spline basis is used to conduct basis expansion.

Usage

1
2
3
4
5
6
NRRR.func(Y, X, jx, jy, degree = 3, S.interval = NULL, T.interval = NULL,
          tuning = c('CV', 'BIC', 'BICP', 'AIC', 'GCV')[1],
          nfold = 10, norder = NULL, method = c('RRR', 'RRS')[1],
          lambda = 0, maxiter = 300, conv = 1e-4,
          dimred = c(TRUE,TRUE,TRUE), rankfix = NULL, xrankfix = NULL,
          yrankfix = NULL, lang = c('R', 'Rcpp')[1])

Arguments

Y

a data frame of the functional responses with d columns for the values of the response components, a column indicating subject ID named as 'ID' and a column of observation times named as 'TIME'.

X

a data frame of the functional predictors with p columns for the values of the predictor components, a column indicating subject ID named as 'ID' and a column of observation times named as 'TIME'. Order of Subject ID should be the SAME as that of Y.

jx

number of basis functions to expand the predictor trajectory.

jy

number of basis functions to expand the response trajectory.

degree

degree of piecewise polynomial. Default is 3. See bs.

S.interval

range of observation times of X, e.g., S.interval = c(0, 1). Default is NULL.

T.interval

range of observation times of Y, e.g., T.interval = c(0, 1). Default is NULL.

tuning

methods to select ranks. If tuning = 'CV', then cross validation is used to select ranks. Otherwise, the selected information criterion is used to select ranks.

nfold

the number of folds used in cross validation. Default is 10.

norder

a vector of length n that assigns samples to multiple folds for cross validation.

method

'RRR' (default): no additional ridge penalty; 'RRS': add an additional ridge penalty.

lambda

the tuning parameter to control the amount of ridge penalization. It is only used when method = 'RRS'. Default is 0.

maxiter

the maximum iteration number of the blockwise coordinate descent algorithm. Default is 300.

conv

the tolerance level used to control the convergence of the blockwise coordinate descent algorithm. Default is 1e-4.

dimred

a vector of logical values to decide whether to use the specified tuning method do rank selection on certain dimensions. TRUE means the rank is selected by the specified tuning method. If dimred[1] = FALSE, r is provided by rankfix or min(jy*d, rank(X)); If dimred[2] = FALSE, rx equals to xrankfix or p; If dimred[3] = FALSE, ry equals to yrankfix or d. Default is c(TRUE, TRUE, TRUE).

rankfix

a user-provided value of r when dimred[1] = FALSE. Default is NULL which leads to r = min(jy*d, rank(X)).

xrankfix

a user-provided value of rx when dimred[2] = FALSE. Default is NULL which leads to rx = p.

yrankfix

a user-provided value of ry when dimred[3] = FALSE. Default is NULL which leads to ry = d.

lang

'R' (default): the R version function is used; 'Rcpp': the Rcpp version function is used.

Details

This function applies a basis expansion and truncation method to transform the functional problem into a classical finite-dimensional regression problem, and then fits a nested reduced-rank regression. The functional observations are commonly collected in a discrete mannar, and before using this function, the functional response observations and functional predictor observations should be saved as a data frame. Data standardization procedures, e.g., centering or scaling, should be conducted before using this function. B-spline basis is used to conduct basis expansion. If the functional data are already processed into an integrated form, functions like NRRR.est, NRRR.ic or NRRR.cv can be used to fit a NRRR model.

Value

The function returns a list:

Ag

the estimated U.

Bg

the estimated V.

Al

the estimated A.

Bl

the estimated B.

C

the estimated coefficient matrix C.

df

the estimated degrees of freedom of the selected model.

sse

the sum of squared errors of the selected model.

ic

a vector containing values of BIC, BICP, AIC, GCV of the selected model.

rx_path

a matrix displays the path of selecting rx with cross validation. Only available when 'CV' is selected.

ry_path

a matrix displays the path of selecting ry with cross validation. Only available when 'CV' is selected.

r_path

a matrix displays the path of selecting r with cross validation. Only available when 'CV' is selected.

rank

the estimated r.

rx

the estimated rx.

ry

the estimated ry.

sseq

sequence of the time points of observing the predictor trajectory.

phi

the basis functions to expand the predictor trajectory.

tseq

sequence of the time points of observing the response trajectory.

psi

the basis functions to expand the response trajectory.

References

Liu, X., Ma, S., & Chen, K. (2020). Multivariate Functional Regression via Nested Reduced-Rank Regularization. arXiv: Methodology.

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
n <- 100
ns <- 80
nt <- 80
p <- 10
d <- 10
jx <- 8
jy <- 8
library(NRRR)
set.seed(3)
# generate functional data
simDat <- NRRR.sim(n = 100, ns = 80, nt = 80, r = 3, rx = 3, ry = 3,
                   jx = 8, jy = 8, p = 10, d = 10, s2n = 1, rho_X = 0.5,
                   rho_E = 0, Sigma = "CorrAR")
# dimension: c(n, d, nt)
dim(simDat$Y)
# dimension: c(n, p, ns)
dim(simDat$X)
# process the functional data into a data frame with columns:
# predictor/response components, subject ID, and observation time

Y <- t(simDat$Y[1,,])
for (i in 2:n){
  Y <- rbind(Y, t(simDat$Y[i,,]))
}
Y <- data.frame(Y)
Y$TIME <- rep(simDat$tseq, n)
Y$ID <- rep(1:n, each = nt) # Y: nt*n rows, d+2 columns
head(Y)

X <- t(simDat$X[1,,])
for (i in 2:n){
  X <- rbind(X, t(simDat$X[i,,]))
}
X <- data.frame(X)
X$TIME <- rep(simDat$sseq, n)
X$ID <- rep(1:n, each = ns) # X: ns*n rows, p+2 columns
head(X)

fit_func <- NRRR.func(Y, X, jx, jy, degree = 3, S.interval = NULL, T.interval = NULL,
                      tuning = c('CV', 'BIC', 'BICP', 'AIC', 'GCV')[2],
                      nfold = 10, norder = NULL, method = c('RRR', 'RRS')[1],
                      lambda = 0, maxiter = 300, conv = 1e-4,
                      dimred = c(TRUE,TRUE,TRUE), rankfix = NULL, xrankfix = NULL,
                      yrankfix = NULL, lang = c('R', 'Rcpp')[1])

xliu-stat/NRRR documentation built on Jan. 9, 2021, 3:23 p.m.