cv.BPST | R Documentation |
This function implements k-fold cross-validation via bivariate penlized spline over triangulation, and returns the mean squared prediction error.
cv.BPST(
Y,
Z,
V,
Tr,
d = 5,
r = 1,
lambda = 10^seq(-6, 6, by = 0.5),
nfold = 10,
Hmtx = TRUE,
Kmtx = TRUE,
QR = TRUE,
TA = TRUE
)
Y |
The response variable observed over the domain.
|
Z |
The cooridinates of dimension |
V |
The |
Tr |
The triangulation matrix of dimention |
d |
The degree of piecewise polynomials – default is 5, and usually |
r |
The smoothness parameter – default is 1, and 0 |
lambda |
The tuning parameter – default is |
Hmtx |
The indicator of whether the smoothness matrix |
Kmtx |
The indicator of whether the energy matrix |
QR |
The indicator of whether a QR decomposition need to be performed on the smoothness matrix – default is |
TA |
The indicator of whether the area of the triangles need to be calculated – default is |
nfolds |
The number of folds – default is 10. Although |
This R program is modified based on the Matlab program written by Ming-Jun Lai from the University of Georgia and Li Wang from the Iowa State University.
lamc |
The tuning parameter selected by k-fold cross validation (CV). |
mspe |
The mean squared prediction error calculated by k-fold cross validation (CV). |
# Triangulation
# Option 1;
data(V1); data(Tr1); d=5; r=1; V=V1; Tr=Tr1;
# Option 2
# data(V2); data(Tr2); d=5; r=1; V=V2; Tr=Tr2;
d=-1; r=1;
# Grid Points
n1.grid=101; n2.grid=101; n.grid=n1.grid*n2.grid;
u.grid=seq(0,1,length.out=n1.grid)
v.grid=seq(0,1,length.out=n2.grid)
uu.grid=rep(u.grid,each=n2.grid)
vv.grid=rep(v.grid,times=n1.grid)
Z.grid=as.matrix(cbind(uu.grid,vv.grid))
func=1; sigma=0.1;
gridpoints=data.BPST(Z.grid,V,Tr,func,sigma,2019)
Y.grid=gridpoints$Y; mu.grid=gridpoints$mu;
ind=gridpoints$ind; ind.grid=(1:n.grid)[ind==1];
# Simulation parameters
n=2000;
ind.sam=sort(sample(ind.grid,n))
Y=as.matrix(gridpoints$Y[ind.sam]); Z=as.matrix(gridpoints$Z[ind.sam,]);
cv.BPST(Y,Z,V,Tr,d,r,lambda=10^seq(-6,6,by=0.5),nfold=10)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.