Description Usage Arguments Details Value Author(s) References See Also Examples
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.
1 2 |
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 |
m |
m+1 is the order of the B-spline basis.
See |
bs |
specify the usage of monotone increasing/decreasing P-splines ("mpi"/"mpd")
as the penalized smoothing basis.
See |
family |
A family object specifying the distribution of |
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 φ.
Object of class "semihregScam" produced.
An object of class "semihregScam" is a list containing the following components:
harScam |
An object of class |
lambda0 |
The frequency of the harmonic compoenent. |
phi0 |
The estimated phase/2pi of the harmonic compoenent. |
esty |
estimated mean for the observations. |
Yuanhao Lai
Pya, N., & Wood, S. N. (2015). Shape constrained additive models. Statistics and Computing, 25(3), 543-559.
scam
.
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")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.