plsfitCV: Penalized Least Square Fit under CV

Description Usage Arguments Details Value Examples

View source: R/plsfitCV.R

Description

This is an internal function of package ggam.

Usage

1
plsfitCV(B, Q2, K, lambda, Y, fx, fold = 5, Z = NULL)

Arguments

B

The bernstein basis matrix.

Q2

The Q2 matrix from QR decomposition of the transpose of the constraint matrix.

K

The energy matrix to construct penalty matrix.

lambda

The smoothing penalty parameter.

Y

Response variable.

fx

indicates whether the term is a fixed d.f. regression. spline (TRUE) or a penalized regression spline (FALSE).

fold

number of folders to do cross validation.

Z

The parametric model matrix. set to 'NULL' if it is not provided.

Details

The method is a computationally efficient means of applying cross validation to the problem of smoothing parameter selection:

\min _ { \boldsymbol { β } , \boldsymbol { γ } } \frac { 1 } { 2 } ≤ft{ \| \mathbf { Y } - \mathbf { Z } \boldsymbol { β } - \mathbf { B } \boldsymbol { γ } \| ^ { 2 } + λ \boldsymbol { γ } ^ { \top } \mathbf { P } γ \right}

subject to constraints \mathbf { H } γ = \mathbf { 0 }. Z is a parametrix design matrix, β a parameter vector, Y a data vector, γ is the berstein coefficients, B is the Bernsterin basis matrix, H is contraint matrix.

Value

A list of fit information.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
library(GgAM)
library(Matrix)
library(BPST)
data("eg2pop_dat")
eg2_V20=eg2pop_dat[['V20']]
eg2_T20=eg2pop_dat[['T20']]
eg2pop=eg2pop_dat[['pop']]
d=2
r=1
sam=eg2pop[sample(1:dim(eg2pop)[1],100),]
B0=basis(eg2_V20,eg2_T20, d, r, sam[,3:4])
B=B0$Bi
ind=B0$Ind.inside
Q2=B0$Q2
K=B0$K
Z=sam[ind,c(5:12)]
Y=sam[ind,'Y']
lambda=10^(seq(-2,5,by=1))
plsfitCV(as.matrix(B),Q2,K,lambda,Y,fx=FALSE,Z=Z)
### without parametric part
plsfitCV(as.matrix(B),Q2,K,lambda,Y,fx=FALSE)

funstatpackages/GgAM documentation built on Nov. 4, 2019, 12:59 p.m.