GetCI_Dense {fdaconcur}R Documentation

Bootstrap pointwise confidence intervals for the coefficient functions in functional concurrent regression for densely observed data.

Description

Bootstrap pointwise confidence intervals for the coefficient functions in functional concurrent regression for densely observed data.

Usage

GetCI_Dense(dat, tGrid, level = 0.95, R = 10, bw, kernel_type)

Arguments

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 'Y'. If a field corresponds to a functional variable, it should be an n-by-m matrix, where each row holds the observations for one subject on the common grid tGrid. If a field corresponds to a scalar covariate, it should be a vector of length n.

tGrid

A vector of length m with the input time points.

level

A number taking values in [0,1] determing the confidence level. Default: 0.95.

R

An integer holding the number of bootstrap replicates. Default: 999.

bw

Scalar holding the bandwidth.

kernel_type

Character holding the kernel type (see Lwls1D for supported kernels).

Value

A list containing the following fields:

CI_beta0

CI for the intercept function — A data frame holding three variables: CIgrid — the time grid where the CIs are evaluated; CI_beta0.lower and CI_beta0.upper — the lower and upper bounds of the CIs for the intercept function on CIgrid.

CI_beta

A list containing CIs for the slope functions — the length of the list is same as the number of covariates. Each list contains the following fields: A data frame holding three variables: CIgrid — the time grid where the CIs are evaluated, CI_beta_j.lower and CI_beta_j.upper — the lower and upper bounds of the CIs for the intercept function on CIgrid for j = 1,2,\dots.

CI_R2

CI the time-varying R^2(t) — A data frame holding three variables: CIgrid — the time grid where the CIs are evaluated, CI_R2.lower and CI_R2.upper — the lower and upper bounds of the CIs for the time-varying R^2(t) on CIgrid.

level

The confidence level of the CIs.

Examples

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)
smres <- smPtFCRegCoef(res, bw =  2.5 / (nGridIn-1), kernel_type = 'epan')
res_CI = GetCI_Dense(dat, tGrid, level = 0.95, R = 10, bw = 2.5 / (nGridIn-1), kernel_type = 'epan')
beta1 = res_CI$CI_beta[[1]] ##extracting CI for beta1
beta1a = beta1$CI_beta1.lower
beta1b = beta1$CI_beta1.upper
true_beta = beta[1,]  ##extracting true coef beta1 in the simulation setting
est_beta = smres$beta[1,] ## ##extracting estimated coef beta1 from 
###fitting the concurrent regression model
plot(beta1$CIgrid, beta1a, type= 'l', ylim = c(0,2)) ##plot of lower CI for beta1
lines(beta1$CIgrid, beta1b) ##plot of lower CI for beta1
lines(beta1$CIgrid, true_beta, col ='red')  
##plot of true coef beta1 in the simulation setting
lines(beta1$CIgrid, est_beta, col ='blue') 
##plot of estimated coef beta1 from fitting the concurrent regression model

[Package fdaconcur version 0.1.2 Index]