semihregScam: Fit the semiparametric harmonic regression with monotone...

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

Fit the semiparametric harmonic regression with monotone generalzied additive model. It utilizes the R package scam. The estimation procedure iterates between the coefficient of the index term and the smooth monotone P-spline function.

Usage

1
2
semihregScam(y, t, lambda0, k = -1, m = 2, bs = c("mpi", "mpd"),
  family = gaussian())

Arguments

y

A vector containg series as columns.

t

A vector of sampled time points.

lambda0

The frequency of the harmonic compoenent.

k

the dimension of the basis used to represent the smooth term. See smooth.construct.mpi.smooth.spec in the R package scam.

m

m+1 is the order of the B-spline basis. See smooth.construct.mpi.smooth.spec in the R package scam.

bs

specify the usage of monotone increasing/decreasing P-splines ("mpi"/"mpd") as the penalized smoothing basis. See shape.constrained.smooth.terms in the R package scam.

family

A family object specifying the distribution of z and link to use in fitting. See glm and family for more details.

Details

Given frequency λ and phase φ, fit a monotonic smoothing term of sinuosoid with a monotone increasing/decreasing P-splines, i.e.,

E[y_t] = g(a_{1} cos(2πλ t)+a_{2} sin(2πλ t) ),\ t=1,...,n,

where y_{t} consists of independet random variables, a_{1}^2+a_{2}^2=1, g(\cdot) is an unknown strictly monotone function in the range [-1,1], 0<f<0.5, φ\in [0,2π] and σ>0. This can be done by using the R package scam in the R package scam. Since the frequency λ is prespecified in the semiparametric harmonic regression model but the phase φ is unknown, then the estimations of the function g(\cdot) and φ is conducted in a iterative way. The general optimizer optim is used to minimize the UBRE of the fitted with respect to φ.

Value

Object of class "semihregScam" produced.

An object of class "semihregScam" is a list containing the following components:

harScam

An object of class scam. See scam in the R package scam.

lambda0

The frequency of the harmonic compoenent.

phi0

The estimated phase/2pi of the harmonic compoenent.

esty

estimated mean for the observations.

Author(s)

Yuanhao Lai

References

Pya, N., & Wood, S. N. (2015). Shape constrained additive models. Statistics and Computing, 25(3), 543-559.

See Also

scam.

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
30
31
32
33
34
35
# Simulate the series
set.seed(193)
g <- function(x){-2*exp(-x^3)}
n <- 50
t <- 1:n
lambda0 <- 0.123
phi0 <- 0.2*2*pi
u <- cos(2*pi*lambda0*t+phi0)
e <- rnorm(n)
y <- g(u)+e

# Plot ther series
par(mfrow=c(1,2))
plot(t,g(u),type="b")
plot(t,y,type="b")
par(mfrow=c(1,1))

# Pre-estimate the frequency and the phase
lambdaRange <- seq(1/n,0.5-1/n,length.out = 5*n)
paraRankLS <- GetFitRankLS(y,t=1:n,lambdaRange)
paraRankLS    

# Fit the semi-harmonic regression
fit1 <- semihregScam(y,t,lambda0=paraRankLS[2],bs="mpi",family=gaussian())
names(fit1)
fit1$esty

# Prediction for the continuous time.
newt <- seq(1,n,0.05) 
head( predy <- predict(fit1,newt)) 

plot(newt,g(cos(2*pi*lambda0*newt+phi0)),
     type="b",pch=19,main="Semiparametric with scam",
     ylim=c(min(predy[,2])-1,max(predy[,2])+0.5) )
lines(newt,predy[,2],col="red",type="l")

CliffordLai/harper documentation built on May 8, 2019, 1:53 p.m.