ptFCReg {fdaconcur} | R Documentation |
Functional concurrent regression using pointwise multiple linear regression.
ptFCReg(tGrid, dat)
tGrid |
A vector of length |
dat |
A list of input functional/scalar covariates.
Each field corresponds to a functional (a matrix) or scalar (a vector) variable.
The last entry is assumed to be the functional response if no entry is names |
A list containing the following fields:
A vector containing the time-varying intercept evaluated on tGrid
.
A matrix for the concurrent regression effects,
where rows correspond to different predictors and columns to different time points in tGrid
.
The input tGrid
.
A vector of the time-varying R^2(t)
, evaluated at t
in tGrid
.
A list holding the input data, each element of which is a data frame holding
the data observed at one element of tGrid
.
set.seed(1)
n <- 50
nGridIn <- 101
tGrid <- seq(0, 1, length.out=nGridIn) # Functional data support
muX1 <- tGrid * 2 # mean function for X_1
sigma <- 1
beta0 <- 0
beta <- rbind(cos(tGrid), 1.5 + sin(tGrid))
Z <- MASS::mvrnorm(n, rep(0, 2), diag(2))
X_1 <- Z[, 1, drop=FALSE] %*% matrix(1, 1, nGridIn) + matrix(muX1, n, nGridIn, byrow=TRUE)
epsilon <- rnorm(n, sd=sigma)
Y <- t(sapply(seq_len(n), function(i) {
beta0 + beta[1,] * X_1[i, ] + beta[2,] * Z[i, 2] + epsilon[i]
}))
dat <- list(X1=X_1, Z1=Z[, 2], Y=Y)
res <- ptFCReg(tGrid = tGrid, dat = dat)