Toeplitz Calculations
toepl_fwd.Rd
Multiplication of stacked data vector with a block Toeplitz matrix (toepl_fwd()
for MA calculations) or
"inversion" of a block Toeplitz matrix in order to perform calculations equivalent to
multiplying a given stacked data vector with the inverse of a lower-triangular banded block Toeplitz matrix (toepl_inv()
for AR calculations).
Note that matrix polynomials can be mapped one-to-one to banded lower-triangular block Toeplitz matrices.
Arguments
- polm_wide
Wide matrix \(( d_0, d_1, \ldots, d_q )\) of dimension \((m \times (q+1) n)\) which represents a matrix polynomial \(d(z)\) of degree \(q\).
- data_in
Data matrix of dimension \((dim(inputs) x nobs)\). Every column corresponds to one observation.
- t0
Integer. Time index where calculations should start. Default set to 1. For AR calculations, \(degree + 1\) would be another smart option.
- polm_rev
Wide matrix \((c_p, ... , c_1)\) of dimension \((n \times (q+1) n)\) with coefficients ordered in reverse direction, and zero-lag coefficient matrix not included. It represents a square polynomial matrix \(c(z)\) with \(c_0\) equal to the identity matrix and of degree \(p\).
MA-type Toeplitz calculations
Given a polynomial matrix of degree \(q\) and dimension \((m \times n)\), where \(m \geq n\), and given a "wide" input data matrix of dimension \((n \times nobs)\), where \(nobs\) is the number of observations such that each column corresponds to one observation and the number of columns is equal to the number of observations, we calculate a "wide" output data matrix of dimension \((m \times nobs)\).
The function name toepl_fwd
stems from the multiplication of the "stacked" input data vector
\((u_1', \ldots , u_{nobs}')'\) with a banded lower-triangular block Toeplitz matrix \(T\)
of dimension \((nobs m \times nobs n)\)
whose block elements depend only on the difference between the row- and column-index
such that \(T_{i,j} = d_{i-j}\).
AR-type Toeplitz calcuations
Given a square polynomial matrix \(c(z)\) for which \(c_0\) is the identity matrix and given
a wide data matrix y = data_in
, obtain the solution u
, a wide data matrix, of the Toeplitz equation
$$T (y_1', \ldots , y_{nobs}')' = (u_1', ... , u_{nobs}')'$$
Note that the zero-lag coefficient is discarded and the coefficients are in reversed order since this simplifies computations and implementation.
Examples
p = test_polm(dim = c(2,2), degree = 2) %>% unclass()
dim(p) = c(2,2*3)
data = matrix(rnorm(2*100), 2, 100)
toepl_fwd(p, data)
#> [,1] [,2] [,3] [,4] [,5] [,6] [,7]
#> [1,] 48.53106 -134.3825 -79.55702 -149.4543 -236.6421 -270.6178 -196.2053
#> [2,] 92.44646 -246.5141 -145.23976 -276.5327 -442.8431 -506.9243 -367.7946
#> [,8] [,9] [,10] [,11] [,12] [,13] [,14]
#> [1,] 119.3014 164.8545 -24.43628 -14.49629 -210.6824 134.2024 -147.3837
#> [2,] 213.1564 306.1961 -60.57406 -40.25072 -399.6319 266.3913 -268.1439
#> [,15] [,16] [,17] [,18] [,19] [,20] [,21]
#> [1,] -100.3575 -531.642 -411.2533 -431.1777 -208.3144 143.4619 45.74733
#> [2,] -196.7382 -1003.930 -770.3672 -804.9451 -385.1286 275.3444 95.98795
#> [,22] [,23] [,24] [,25] [,26] [,27] [,28]
#> [1,] 98.82395 -250.3182 -91.01261 -79.63828 -136.0059 -178.5274 -389.1817
#> [2,] 184.29770 -459.8291 -166.68878 -139.48684 -257.3182 -334.7480 -724.3919
#> [,29] [,30] [,31] [,32] [,33] [,34] [,35]
#> [1,] -234.4082 -549.4613 -506.7492 -303.9775 204.8983 276.6762 22.09023
#> [2,] -428.4322 -1021.9773 -944.4421 -563.0312 377.5595 518.3874 41.21092
#> [,36] [,37] [,38] [,39] [,40] [,41] [,42]
#> [1,] 74.81879 387.4503 662.9986 643.0209 288.1410 286.4461 -305.0684
#> [2,] 152.76199 741.2716 1247.4625 1193.3869 526.8873 521.9721 -558.4257
#> [,43] [,44] [,45] [,46] [,47] [,48] [,49]
#> [1,] -369.6217 -766.8042 -295.9381 12.77775 247.6784 295.2095 310.2952
#> [2,] -682.5752 -1404.8734 -541.6796 39.28384 476.7815 565.9677 597.8852
#> [,50] [,51] [,52] [,53] [,54] [,55] [,56]
#> [1,] 370.0766 -73.21673 -60.84073 -104.1125 506.9061 536.2543 670.3389
#> [2,] 702.6121 -132.46358 -117.83679 -203.7706 924.7643 988.2501 1241.7359
#> [,57] [,58] [,59] [,60] [,61] [,62] [,63]
#> [1,] 343.8154 225.6153 -15.50606 -53.07058 -199.5526 -69.20161 249.4676
#> [2,] 637.2784 423.1739 -27.76819 -97.83486 -376.2309 -126.00998 465.1832
#> [,64] [,65] [,66] [,67] [,68] [,69] [,70]
#> [1,] 262.3669 306.6835 161.2361 -19.75846 -161.9647 -152.9479 -116.1847
#> [2,] 485.3093 571.6796 290.0654 -47.49593 -304.1064 -275.6184 -214.4478
#> [,71] [,72] [,73] [,74] [,75] [,76] [,77]
#> [1,] -131.8496 -207.7715 -88.33973 -409.0906 -687.2381 -886.5979 -670.1362
#> [2,] -251.7958 -394.8257 -166.60984 -774.0724 -1291.9125 -1657.0778 -1244.4204
#> [,78] [,79] [,80] [,81] [,82] [,83] [,84]
#> [1,] -260.8985 -189.7515 -56.97477 -219.380 -121.9303 -55.45676 40.94456
#> [2,] -468.1126 -345.7494 -101.52164 -410.221 -223.4252 -106.75769 66.56274
#> [,85] [,86] [,87] [,88] [,89] [,90] [,91]
#> [1,] 34.01301 -283.0913 -284.7730 -208.9906 9.599048 202.1940 92.26289
#> [2,] 47.43279 -536.9144 -525.6667 -390.4657 12.554077 362.3666 162.29454
#> [,92] [,93] [,94] [,95] [,96] [,97] [,98]
#> [1,] 165.7306 44.25920 348.7652 192.1822 93.00929 -268.5972 -227.6764
#> [2,] 303.1613 84.74469 642.9034 342.4069 159.06386 -512.9726 -425.7729
#> [,99] [,100]
#> [1,] -33.78185 249.8006
#> [2,] -63.06538 468.2370
p = test_polm(dim = c(2,2), degree = 2) %>% unclass()
dim(p) = c(2,2*3)
data = matrix(rnorm(2*100), 2, 100)
toepl_inv(p, data)
#> [,1] [,2] [,3] [,4] [,5] [,6]
#> [1,] 0.2292931 -49.48023 17292.16 -5807595 1951206529 -6.555537e+11
#> [2,] 0.2087030 -96.72532 31868.99 -10709134 3597977994 -1.208825e+12
#> [,7] [,8] [,9] [,10] [,11]
#> [1,] 2.202487e+14 -7.399774e+16 2.486128e+19 -8.352732e+21 2.806297e+24
#> [2,] 4.061334e+14 -1.364501e+17 4.584361e+19 -1.540224e+22 5.174745e+24
#> [,12] [,13] [,14] [,15] [,16]
#> [1,] -9.428415e+26 3.167698e+29 -1.064263e+32 3.575641e+34 -1.201321e+37
#> [2,] -1.738577e+27 5.841160e+29 -1.962475e+32 6.593397e+34 -2.215207e+37
#> [,17] [,18] [,19] [,20] [,21]
#> [1,] 4.036120e+39 -1.356029e+42 4.555900e+44 -1.530662e+47 5.142619e+49
#> [2,] 7.442509e+39 -2.500486e+42 8.400971e+44 -2.822504e+47 9.482867e+49
#> [,22] [,23] [,24] [,25] [,26]
#> [1,] -1.727784e+52 5.804897e+54 -1.950292e+57 6.552464e+59 -2.201454e+62
#> [2,] -3.185992e+52 1.070409e+55 -3.596291e+57 1.208259e+60 -4.059429e+62
#> [,27] [,28] [,29] [,30] [,31]
#> [1,] 7.396304e+64 -2.484962e+67 8.348816e+69 -2.804981e+72 9.423995e+74
#> [2,] 1.363861e+65 -4.582211e+67 1.539502e+70 -5.172319e+72 1.737762e+75
#> [,32] [,33] [,34] [,35] [,36]
#> [1,] -3.166213e+77 1.063764e+80 -3.573965e+82 1.200758e+85 -4.034228e+87
#> [2,] -5.838421e+77 1.961555e+80 -6.590306e+82 2.214168e+85 -7.439019e+87
#> [,37] [,38] [,39] [,40] [,41]
#> [1,] 1.355394e+90 -4.553764e+92 1.529944e+95 -5.140208e+97 1.726974e+100
#> [2,] 2.499314e+90 -8.397032e+92 2.821181e+95 -9.478421e+97 3.184498e+100
#> [,42] [,43] [,44] [,45] [,46]
#> [1,] -5.802175e+102 1.949377e+105 -6.549392e+107 2.200422e+110 -7.392836e+112
#> [2,] -1.069907e+103 3.594605e+105 -1.207692e+108 4.057526e+110 -1.363221e+113
#> [,47] [,48] [,49] [,50] [,51]
#> [1,] 2.483797e+115 -8.344902e+117 2.803666e+120 -9.419577e+122 3.164728e+125
#> [2,] 4.580063e+115 -1.538780e+118 5.169894e+120 -1.736947e+123 5.835684e+125
#> [,52] [,53] [,54] [,55] [,56]
#> [1,] -1.063265e+128 3.572289e+130 -1.200195e+133 4.032336e+135 -1.354758e+138
#> [2,] -1.960635e+128 6.587216e+130 -2.213130e+133 7.435532e+135 -2.498142e+138
#> [,57] [,58] [,59] [,60] [,61]
#> [1,] 4.551629e+140 -1.529227e+143 5.137798e+145 -1.726164e+148 5.799455e+150
#> [2,] 8.393096e+140 -2.819858e+143 9.473977e+145 -3.183005e+148 1.069406e+151
#> [,62] [,63] [,64] [,65] [,66]
#> [1,] -1.948463e+153 6.546321e+155 -2.199391e+158 7.389370e+160 -2.482633e+163
#> [2,] -3.592920e+153 1.207126e+156 -4.055624e+158 1.362582e+161 -4.577916e+163
#> [,67] [,68] [,69] [,70] [,71]
#> [1,] 8.340990e+165 -2.802352e+168 9.415160e+170 -3.163245e+173 1.062767e+176
#> [2,] 1.538059e+166 -5.167470e+168 1.736133e+171 -5.832948e+173 1.959716e+176
#> [,72] [,73] [,74] [,75] [,76]
#> [1,] -3.570614e+178 1.199632e+181 -4.030446e+183 1.354123e+186 -4.549495e+188
#> [2,] -6.584127e+178 2.212093e+181 -7.432046e+183 2.496971e+186 -8.389161e+188
#> [,77] [,78] [,79] [,80] [,81]
#> [1,] 1.528510e+191 -5.135389e+193 1.725355e+196 -5.796736e+198 1.947550e+201
#> [2,] 2.818536e+191 -9.469535e+193 3.181513e+196 -1.068904e+199 3.591235e+201
#> [,82] [,83] [,84] [,85] [,86]
#> [1,] -6.543252e+203 2.198359e+206 -7.385906e+208 2.481469e+211 -8.337079e+213
#> [2,] -1.206560e+204 4.053722e+206 -1.361943e+209 4.575769e+211 -1.537337e+214
#> [,87] [,88] [,89] [,90] [,91]
#> [1,] 2.801038e+216 -9.410746e+218 3.161762e+221 -1.062268e+224 3.56894e+226
#> [2,] 5.165047e+216 -1.735319e+219 5.830213e+221 -1.958797e+224 6.58104e+226
#> [,92] [,93] [,94] [,95] [,96]
#> [1,] -1.199069e+229 4.028556e+231 -1.353488e+234 4.547362e+236 -1.527793e+239
#> [2,] -2.211055e+229 7.428561e+231 -2.495800e+234 8.385227e+236 -2.817214e+239
#> [,97] [,98] [,99] [,100]
#> [1,] 5.132981e+241 -1.724546e+244 5.794018e+246 -1.946637e+249
#> [2,] 9.465095e+241 -3.180021e+244 1.068403e+247 -3.589552e+249