plsfitGCV: Penalized Least Square Fit under GCV

Description Usage Arguments Details Value Examples

View source: R/plsfitGCV.R

Description

This is an internal function of package ggam.

Usage

1
plsfitGCV(B, Q2, P, lambda, Y, fx, Z = NULL, ...)

Arguments

B

The bernstein basis matrix.

Q2

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

P

The 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).

Z

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

...

other arguments.

Details

The method is a computationally efficient means of applying GCV 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
library(Matrix)
library(BPST)
data("eg1pop_dat")
eg1_V1=eg1pop_dat[['V1']]
eg1_T1=eg1pop_dat[['T1']]
eg1pop_rho03=eg1pop_dat[['rho03']]
sam=eg1pop_rho03[sample(1:dim(eg1pop_rho03)[1],100),]
B0=basis(eg1_V1,eg1_T1, d=2, r=1, sam[,3:4])
B=B0$Bi
ind=B0$Ind.inside
Q2=B0$Q2
K=B0$K
P=t(Q2)%*%K%*%Q2
Z=sam[ind,c(5:12)]
Y=sam[ind,'Y']
lambda=10^(seq(-2,5,by=1))
plsfitGCV(as.matrix(B),Q2,P,lambda,Y,fx=FALSE,Z=Z)

### without parametric part
plsfitGCV(as.matrix(B),Q2,P,lambda,Y,fx=FALSE)

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