cv.FDAimage: Cross-validation for Imga-on-Scalar Regression

Description Usage Arguments Details Value Examples

View source: R/cv.FDAimage.R

Description

This function implements k-fold cross-validation for image-on-scalar regression, and returns the mean squared prediction error.

Usage

1
2
cv.FDAimage(Y, X, Z, V, Tr, d = 5, r = 1, lambda = 10^seq(-6, 6, by =
  0.5), nfold = 10, iter = 2019)

Arguments

Y

The response images of dimension n by npix, where n is the number of observed images and npix is the number of pixels/voxels in each image. Each row is an observation of the images.

X

The design matrix of dimension n by p, with an intercept. Each row is an observation vector.

Z

The cooridinates of dimension npix by two. Each row is the coordinates of a pixel/voxel.

V

The N by two matrix of vertices of a triangulation, where N is the number of vertices. Each row is the coordinates for a vertex.

Tr

The triangulation matrix of dimention nT by three, where nT is the number of triangles in the triangulation. Each row is the indices of vertices in V.

d

The degree of piecewise polynomials – default is 5, and -1 represents piecewise constant.

r

The smoothness parameter – default is 1, and 0 r < d.

lambda

The vector of the candidates of penalty parameter – default is grid points of 10 to the power of a sequence from -6 to 6 by 0.5.

iter

The seed used for cross-validation.

nfolds

The number of folds – default is 10. Although nfold can be as large as the sample size (leave-one-out CV), it is not recommended for large datasets. Smallest value allowable for nfolds is 3.

Details

This R package is the implementation program for manuscript entitled "Multivariate Spline Estimation and Inference for Image-on-Scalar Regression" by Shan Yu, Guannan Wang, Li Wang and Lijian Yang.

Value

mspe

The mean squared prediction error based on k-fold cross validation (CV).

lamc

The tuning parameter selected by k-fold cross validation (CV).


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
# Libraries and source files needed
library(devtools)
install_github("funstatpackages/BPST")
library(BPST)
install_github("funstatpackages/Triangulation")
library(Triangulation)
# Location information
n1=95; n2=79;
u1=seq(0,1,length.out=n1)
v1=seq(0,1,length.out=n2)
uu=rep(u1,each=n2)
vv=rep(v1,times=n1)
uu.mtx=matrix(uu,n2,n1)
vv.mtx=matrix(vv,n2,n1)
Z=as.matrix(cbind(uu,vv))
# Parameters
d=5; r=1; rho=0.5; nfold=10; alpha0=0.05;
# Triangulation
data(V1); data(Tr1); # triangulation_1 in the paper;
# data(brain_boundary); # brain imaging boundary of slide 48;
V=V1; Tr=Tr1;
ind=inVT(V,Tr,Z[,1],Z[,2])
ind.inside=ind$ind.inside; ind=ind$ind;
n=50; sigma=0.5; lambda1=0.03; lambda2=0.006;
dat=data.FDAimage(n,Z,ind.inside,sigma,rho,2019,lambda1,lambda2)
Y=dat$Y; X=dat$X; Z=dat$Z;
Y=Y[,ind.inside] # remove the points which are outside the boundary;
lambda=10^(seq(-6,6,by=1))
cv.FDAimage(Y,X,Z,V,Tr,d,r,lambda,nfold,iter)

funstatpackages/FDAimage documentation built on Oct. 11, 2019, 12:50 p.m.