Learn R Programming

timsac (version 1.2.7)

ngsmth: Non-Gaussian Smoothing

Description

Trend estimation by Non-Gaussian smoothing.

Usage

ngsmth(y, noisev=2, tau2, bv=1.0, noisew=1, sig2, bw=1.0, 
         initd=1, k=200, plot=TRUE)

Arguments

y
a univariate time series.
noisev
type of system noise density. 1 : Gaussian (normal), 2 : Pearson family, 3 : two-sided exponential
tau2
variance of dispersion of system noise.
bv
shape parameter of system noise (for noisev=2).
noisew
type of observation noise density. 1 : Gaussian (normal), 2 : Pearson family, 3 : two-sided exponential, 4 : double exponential
sig2
variance of dispersion of observation noise.
bw
shape parameter of observation noise (for noisew=2).
initd
type of density function. 1 : Gaussian (normal), 2 : uniform, 3 : two-sided exponential
k
number of intervals
plot
logical. If TRUE (default) trend and smt are plotted.

Value

  • trendtrend.
  • smtsmoothed density.
  • lkhoodlog-likelihood.

Details

Consider a one dimensional state space model $$x(n) = x(n-1) + v(n),$$ $$y(n) = x(n) + w(n),$$ where the observation noise $w(n)$ is assumed to be Gaussian distributed and the system noise $v(n)$ is assumed to be distributed as the Pearson system $$q(v(n)) = c/(\tau^2 + v(n)^2)^b$$ with $\frac{1}{2} < b < \infty$ and $c = \tau^{2b-1}\Gamma(b) \bigm/ \Gamma(\frac{1}{2})\Gamma(b-\frac{1}{2})$. This broad family of distributions includes the Cauchy distribution ($b=1$).

References

Kitagawa, G., (1993) Time series analysis programing (in Japanese). The Iwanami Computer Science Series. Kitagawa, G. and Gersch, W., (1996) Smoothness Priors Analysis of Time Series. Lecture Notes in Statistics, No.116, Springer-Verlag.

Examples

Run this code
## trend model
  x <- rep(0,400)
  x[101:200] <- 1
  x[201:300] <- -1
  y <- x + rnorm(400, mean=0, sd=0.5)

  # system noise density : Pearson family
  z1 <- ngsmth(y,, 2.11e-10,, 2, 1.042)

  # system noise density : Gaussian (normal)
  z2 <- ngsmth(y, 1, 1.4e-02,, 2, 1.048)

  ##  an earthquake wave data
  data(MYE1F)
  n <- length(MYE1F)
  m <- n/2
  y <- rep(0, n)
  for( i in 2:n )  y[i] <- MYE1F[i] - 0.5*MYE1F[i-1]
  yy <- rep(0, m)
  for( i in 1:m ) yy[i] <- y[i*2]
  z <- tvvar(yy, 2, 6.6e-06, 1.0e-06, FALSE)

  # system noise density : Pearson family
  z1 <- ngsmth(z$ts, 2, 2.6e-04,, 2, 1.644934, k=190)

  # system noise density : Gaussian (normal)
  z2 <- ngsmth(z$ts, 1, 4.909e-02,, 2, 1.644934, k=190)

Run the code above in your browser using DataLab