dlmModTrig: Create Fourier representation of a periodic DLM component

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

Description

The function creates a dlm representing a specified periodic component.

Usage

1
dlmModTrig(s, q, om, tau, dV = 1, dW = 0, m0, C0)

Arguments

s

the period, if integer.

q

number of harmonics in the DLM.

om

the frequency.

tau

the period, if not an integer.

dV

variance of the observation noise.

dW

a single number expressing the variance of the system noise.

m0

m0, the expected value of the pre-sample state vector.

C0

C0, the variance matrix of the pre-sample state vector.

Details

The periodic component is specified by one and only one of s, om, and tau. When s is given, the function assumes that the period is an integer, while a period specified by tau is assumed to be noninteger. Instead of tau, the frequency om can be specified. The argument q specifies the number of harmonics to include in the model. When tau or omega is given, then q is required as well, since in this case the implied Fourier representation has infinitely many harmonics. On the other hand, if s is given, q defaults to all the harmonics in the Fourier representation, that is floor(s/2).

The system variance of the resulting dlm is dW times the identity matrix of the appropriate dimension.

Value

An object of class dlm, representing a periodic component.

Author(s)

Giovanni Petris GPetris@uark.edu

References

Giovanni Petris (2010), An R Package for Dynamic Linear Models. Journal of Statistical Software, 36(12), 1-16. http://www.jstatsoft.org/v36/i12/.
Petris, Petrone, and Campagnoli, Dynamic Linear Models with R, Springer (2009).
West and Harrison, Bayesian forecasting and dynamic models (2nd ed.), Springer (1997).

See Also

dlmModSeas, dlmModARMA, dlmModPoly, dlmModReg

Examples

1
2
3
4
5
6
7
8
dlmModTrig(s = 3)
dlmModTrig(tau = 3, q = 1) # same thing
dlmModTrig(s = 4) # for quarterly data
dlmModTrig(s = 4, q = 1)
dlmModTrig(tau = 4, q = 2) # a bad idea!
m1 <- dlmModTrig(tau = 6.3, q = 2); m1
m2 <- dlmModTrig(om = 2 * pi / 6.3, q = 2)
all.equal(unlist(m1), unlist(m2))

Example output

$FF
     [,1] [,2]
[1,]    1    0

$V
     [,1]
[1,]    1

$GG
           [,1]       [,2]
[1,] -0.5000000  0.8660254
[2,] -0.8660254 -0.5000000

$W
     [,1] [,2]
[1,]    0    0
[2,]    0    0

$m0
[1] 0 0

$C0
      [,1]  [,2]
[1,] 1e+07 0e+00
[2,] 0e+00 1e+07

$FF
     [,1] [,2]
[1,]    1    0

$V
     [,1]
[1,]    1

$GG
           [,1]       [,2]
[1,] -0.5000000  0.8660254
[2,] -0.8660254 -0.5000000

$W
     [,1] [,2]
[1,]    0    0
[2,]    0    0

$m0
[1] 0 0

$C0
      [,1]  [,2]
[1,] 1e+07 0e+00
[2,] 0e+00 1e+07

$FF
     [,1] [,2] [,3]
[1,]    1    0    1

$V
     [,1]
[1,]    1

$GG
              [,1]         [,2] [,3]
[1,]  6.123234e-17 1.000000e+00    0
[2,] -1.000000e+00 6.123234e-17    0
[3,]  0.000000e+00 0.000000e+00   -1

$W
     [,1] [,2] [,3]
[1,]    0    0    0
[2,]    0    0    0
[3,]    0    0    0

$m0
[1] 0 0 0

$C0
      [,1]  [,2]  [,3]
[1,] 1e+07 0e+00 0e+00
[2,] 0e+00 1e+07 0e+00
[3,] 0e+00 0e+00 1e+07

$FF
     [,1] [,2]
[1,]    1    0

$V
     [,1]
[1,]    1

$GG
              [,1]         [,2]
[1,]  6.123234e-17 1.000000e+00
[2,] -1.000000e+00 6.123234e-17

$W
     [,1] [,2]
[1,]    0    0
[2,]    0    0

$m0
[1] 0 0

$C0
      [,1]  [,2]
[1,] 1e+07 0e+00
[2,] 0e+00 1e+07

$FF
     [,1] [,2] [,3] [,4]
[1,]    1    0    1    0

$V
     [,1]
[1,]    1

$GG
              [,1]         [,2]          [,3]          [,4]
[1,]  6.123234e-17 1.000000e+00  0.000000e+00  0.000000e+00
[2,] -1.000000e+00 6.123234e-17  0.000000e+00  0.000000e+00
[3,]  0.000000e+00 0.000000e+00 -1.000000e+00  1.224647e-16
[4,]  0.000000e+00 0.000000e+00 -1.224647e-16 -1.000000e+00

$W
     [,1] [,2] [,3] [,4]
[1,]    0    0    0    0
[2,]    0    0    0    0
[3,]    0    0    0    0
[4,]    0    0    0    0

$m0
[1] 0 0 0 0

$C0
      [,1]  [,2]  [,3]  [,4]
[1,] 1e+07 0e+00 0e+00 0e+00
[2,] 0e+00 1e+07 0e+00 0e+00
[3,] 0e+00 0e+00 1e+07 0e+00
[4,] 0e+00 0e+00 0e+00 1e+07

$FF
     [,1] [,2] [,3] [,4]
[1,]    1    0    1    0

$V
     [,1]
[1,]    1

$GG
           [,1]      [,2]       [,3]       [,4]
[1,]  0.5425463 0.8400259  0.0000000  0.0000000
[2,] -0.8400259 0.5425463  0.0000000  0.0000000
[3,]  0.0000000 0.0000000 -0.4112871  0.9115059
[4,]  0.0000000 0.0000000 -0.9115059 -0.4112871

$W
     [,1] [,2] [,3] [,4]
[1,]    0    0    0    0
[2,]    0    0    0    0
[3,]    0    0    0    0
[4,]    0    0    0    0

$m0
[1] 0 0 0 0

$C0
      [,1]  [,2]  [,3]  [,4]
[1,] 1e+07 0e+00 0e+00 0e+00
[2,] 0e+00 1e+07 0e+00 0e+00
[3,] 0e+00 0e+00 1e+07 0e+00
[4,] 0e+00 0e+00 0e+00 1e+07

[1] TRUE

dlm documentation built on May 2, 2019, 4:58 p.m.