simulate.midas_r: Simulate MIDAS regression response

Description Usage Arguments Details Value Author(s) Examples

View source: R/simulate.R

Description

Simulates one or more responses from the distribution corresponding to a fitted MIDAS regression object.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## S3 method for class 'midas_r'
simulate(
  object,
  nsim = 999,
  seed = NULL,
  future = TRUE,
  newdata = NULL,
  insample = NULL,
  method = c("static", "dynamic"),
  innov = NULL,
  show_progress = TRUE,
  ...
)

Arguments

object

midas_r object

nsim

number of simulations

seed

either NULL or an integer that will be used in a call to set.seed before simulating the time series. The default, NULL will not change the random generator state.

future

logical, if TRUE forecasts are simulated, if FALSE in-sample simulation is performed.

newdata

a named list containing future values of mixed frequency regressors. The default is NULL, meaning that only in-sample data is used.

insample

a list containing the historic mixed frequency data

method

the simulation method, if "static" in-sample values for dependent variable are used in autoregressive MIDAS model, if "dynamic" the dependent variable values are calculated step-by-step from the initial in-sample values.

innov

a matrix containing the simulated innovations. The default is NULL, meaning, that innovations are simulated from model residuals.

show_progress

logical, TRUE to show progress bar, FALSE for silent evaluation

...

not used currently

Details

Only the regression innovations are simulated, it is assumed that the predictor variables and coefficients are fixed. The innovation distribution is simulated via bootstrap.

Value

a matrix of simulated responses. Each row contains a simulated response.

Author(s)

Virmantas Kvedaras, Vaidotas Zemlys

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
data("USrealgdp")
data("USunempr")

y <- diff(log(USrealgdp))
x <- window(diff(USunempr), start = 1949)
trend <- 1:length(y)

##24 high frequency lags of x included
mr <- midas_r(y ~ trend + fmls(x, 23, 12, nealmon), start = list(x = rep(0, 3)))

simulate(mr, nsim=10, future=FALSE)

##Forecast horizon
h <- 3
##Declining unemployment
xn <- rep(-0.1, 12*3)
##New trend values
trendn <- length(y) + 1:h

simulate(mr, nsim = 10, future = TRUE, newdata = list(trend = trendn, x = xn))

Example output

Loading required package: sandwich
Loading required package: optimx
Loading required package: quantreg
Loading required package: SparseM

Attaching package: 'SparseM'

The following object is masked from 'package:base':

    backsolve

              [,1]         [,2]         [,3]          [,4]         [,5]
 [1,]  0.086994161  0.066145627  0.077464784  0.0929377160  0.080313030
 [2,]  0.076620783  0.075185495  0.066631245  0.0624687389  0.077191839
 [3,]  0.051310380  0.062464468  0.055245941  0.0386820023  0.053814758
 [4,]  0.036213859  0.033347654  0.047345485  0.0511990671  0.037153749
 [5,] -0.001737986 -0.012905160 -0.003285350 -0.0027537285 -0.007987541
 [6,]  0.072723425  0.072723425  0.062506941  0.0775668202  0.076253634
 [7,]  0.041648970  0.041648970  0.042237456  0.0451737093  0.044330175
 [8,]  0.034276184  0.036529207  0.013022506  0.0389506529  0.022124376
 [9,] -0.004308391 -0.004492701 -0.005598101 -0.0007363188 -0.003776769
[10,]  0.081740392  0.062826931  0.070676120  0.0578202112  0.067695075
[11,]  0.035071397  0.011272580  0.039044721  0.0350713967  0.029055183
[12,]  0.021411697  0.006976010  0.023067474  0.0305559645  0.028335644
[13,]  0.050572336  0.064220096  0.061201872  0.0544499953  0.044456453
[14,]  0.035853232  0.043449719  0.043526227  0.0412907248  0.019943018
[15,]  0.047657481  0.033728994  0.053732385  0.0471938350  0.046164421
[16,]  0.057342328  0.044696953  0.051089803  0.0510898035  0.053081813
[17,]  0.041772118  0.045686855  0.051950838  0.0564952182  0.037469499
[18,]  0.036988889  0.039081608  0.019965050  0.0324366521  0.014332700
[19,]  0.058426401  0.022887672  0.037187963  0.0360536019  0.042448510
[20,]  0.027119399  0.032995901  0.033446031  0.0295312937  0.042766001
[21,] -0.008454706 -0.003826541 -0.001174668  0.0090170673  0.012870650
[22,]  0.016783835  0.028357335  0.034040195  0.0178268468  0.028357335
[23,]  0.039137572  0.036725678  0.043063767  0.0493162913  0.051858433
[24,]  0.050008192  0.046087256  0.054793124  0.0548757594  0.050914283
[25,]  0.016980724  0.014143954  0.009665344  0.0139402741  0.019435445
[26,] -0.013128855 -0.014283077 -0.011416873 -0.0083215213 -0.002110419
[27,]  0.049918102  0.054139291  0.046937057  0.0428845028  0.049276828
[28,]  0.065666699  0.049224605  0.056969721  0.0609052817  0.050667975
[29,]  0.052901013  0.057795597  0.047667201  0.0459770660  0.043829183
[30,]  0.040176826  0.039076666  0.032431710  0.0274936874  0.049866486
[31,] -0.002755884  0.002767383 -0.001043901  0.0044679542 -0.006884301
[32,]  0.033874930  0.016147349  0.009421858  0.0111538343  0.027589187
[33,] -0.011259856 -0.013415317 -0.019615754 -0.0174678707 -0.010434272
[34,]  0.055696170  0.061209116  0.061209116  0.0626402985  0.038488020
[35,]  0.063559908  0.078310864  0.061903127  0.0666053172  0.070378928
[36,]  0.028642357  0.034355093  0.018708146  0.0312559460  0.026930689
[37,]  0.024889079  0.017459488  0.030007288  0.0433437427  0.036399614
[38,]  0.029260171  0.055874281  0.033160545  0.0448927555  0.052835972
[39,]  0.046322328  0.040277207  0.047142457  0.0505145138  0.044305687
[40,]  0.041517425  0.035308598  0.029581652  0.0353085982  0.036216281
[41,]  0.028415381  0.010366069  0.012256794  0.0096619685  0.029391788
[42,]  0.009396707  0.013943115  0.001049442 -0.0087706215  0.006426196
[43,]  0.034828892  0.028518200  0.015893514  0.0198934389  0.014520369
[44,]  0.036215352  0.042042235  0.048229709  0.0381274978  0.059498070
[45,]  0.048273623  0.046706649  0.056561605  0.0442736979  0.028434016
[46,]  0.040996764  0.037209929  0.037466555  0.0350992601  0.029685264
[47,]  0.041886718  0.032578205  0.026240116  0.0428040542  0.041886718
[48,]  0.021655821  0.035823224  0.034203621  0.0283813114  0.028081629
[49,]  0.050253317  0.015262648  0.029698335  0.0264160899  0.035906350
[50,]  0.037671568  0.032393966  0.037671568  0.0125988753  0.028231460
[51,]  0.026886457  0.012419919  0.032259527  0.0283301332  0.044737870
[52,]  0.021329407  0.003423443  0.005877041 -0.0117733746  0.007902053
[53,]  0.011940436  0.012174689  0.006100036 -0.0019880515  0.017128506
[54,]  0.029103898  0.030732285  0.037950813  0.0146680947  0.024644074
[55,]  0.020628473  0.040807427  0.039140140  0.0188964974  0.039383987
[56,]  0.043994396  0.027835809  0.034162440  0.0423180806  0.039098603
[57,]  0.041414808  0.015077955  0.015077955  0.0186978174  0.031203776
[58,]  0.028514270  0.025560216  0.026660376  0.0236518077  0.018660163
[59,] -0.008063662 -0.014138314 -0.014692823 -0.0172328878 -0.008297915
[60,] -0.042997153 -0.051768162 -0.036458604 -0.0354802342 -0.037021652
[61,]  0.027509951  0.025113174  0.012641572  0.0265565435  0.032744018
[62,]  0.025516645  0.043457167  0.031885095  0.0410017661  0.040782904
              [,6]          [,7]         [,8]          [,9]         [,10]
 [1,]  0.062245252  0.0856173739  0.062245252  8.594167e-02  0.0786934267
 [2,]  0.075189600  0.0611364455  0.068386944  7.242860e-02  0.0507365286
 [3,]  0.053617554  0.0397616033  0.052075423  3.758423e-02  0.0310936625
 [4,]  0.042288762  0.0422887622  0.041401929  1.665302e-02  0.0423878166
 [5,]  0.010877306 -0.0079875410  0.002227596  2.223491e-03 -0.0032853503
 [6,]  0.060594795  0.0724667989  0.049102452  7.268566e-02  0.0732869281
 [7,]  0.021809362  0.0479347131  0.047847972  3.341585e-02  0.0299074497
 [8,]  0.030355249  0.0374085217  0.035867104  4.534046e-02  0.0298916026
 [9,] -0.005081187 -0.0005347797 -0.016822708 -2.151654e-02 -0.0037767688
[10,]  0.084197503  0.0662915378  0.057520529  7.158221e-02  0.0494224416
[11,]  0.038639371  0.0195862755  0.029760821  3.567266e-02  0.0319162821
[12,]  0.010595873  0.0285393238  0.018129452  3.331286e-02  0.0231018312
[13,]  0.045978669  0.0642200957  0.061201872  4.918739e-02  0.0456789865
[14,]  0.044329034  0.0268185727  0.046582215  4.541789e-02  0.0197274107
[15,]  0.046234952  0.0557996057  0.058789107  4.372923e-02  0.0471938350
[16,]  0.053081813  0.0453656091  0.057380092  3.354351e-02  0.0496349758
[17,]  0.039974119  0.0466402623  0.054488874  5.177528e-02  0.0542957757
[18,]  0.037814473  0.0378144734  0.029965285  4.074527e-02  0.0199650503
[19,]  0.034217637  0.0285200226  0.033513537  3.672226e-02  0.0522669499
[20,]  0.039534450  0.0405128197  0.042165414  3.344603e-02  0.0484447553
[21,] -0.010345431  0.0066739442 -0.010345431 -9.552479e-03  0.0041359076
[22,]  0.030509985  0.0392069633  0.010293268  3.920696e-02  0.0267286200
[23,]  0.043052309  0.0472014048  0.032608637  3.413085e-02  0.0366709170
[24,]  0.047027147  0.0460872564  0.062065147  4.036100e-02  0.0559056966
[25,]  0.012118942  0.0008943353  0.012635855  1.011547e-02  0.0070163270
[26,] -0.002110419 -0.0104769821 -0.011416873 -1.143039e-02 -0.0072812932
[27,]  0.042068913  0.0320686788  0.040736620  4.553352e-02  0.0367625111
[28,]  0.054696455  0.0417465180  0.051621382  5.066797e-02  0.0599879450
[29,]  0.044748424  0.0486260832  0.038632541  6.407494e-02  0.0427495818
[30,]  0.014327758  0.0371682574  0.038024175  3.412285e-02  0.0446834421
[31,]  0.006009372 -0.0092747737  0.002971063  4.467954e-03 -0.0001040104
[32,]  0.028893605  0.0158476667  0.023659793  2.602221e-02  0.0193560693
[33,] -0.008181249 -0.0045367674 -0.005649340 -8.280304e-03 -0.0174678707
[34,]  0.034868157  0.0493038443  0.043481535  5.859047e-02  0.0348681574
[35,]  0.068837511  0.0666053172  0.080767974  4.766519e-02  0.0671369390
[36,]  0.017035867  0.0148077716  0.028528210  3.435509e-02  0.0381798931
[37,]  0.035626817  0.0362153033  0.036399614  2.919170e-02  0.0287786461
[38,]  0.049760899  0.0662633272  0.041383088  5.812746e-02  0.0581274627
[39,]  0.045478793  0.0350301764  0.033950575  4.734400e-02  0.0465411891
[40,]  0.040600088  0.0254532349  0.035104918  3.152789e-02  0.0352145700
[41,]  0.004668454  0.0254486750  0.022408225  1.548428e-02  0.0185948833
[42,]  0.011812489  0.0068877839  0.006426196 -8.770622e-03  0.0068877839
[43,]  0.026175077  0.0281814204  0.022574644 -2.174264e-03  0.0323717822
[44,]  0.041592105  0.0391895463  0.051362205  3.812750e-02  0.0451511025
[45,]  0.045753242  0.0418385049  0.050593785  3.992636e-02  0.0509548285
[46,]  0.013629974  0.0311648081  0.028312120  4.715622e-02  0.0138455819
[47,]  0.038868494  0.0251423431  0.018651776  2.971406e-02  0.0388307296
[48,]  0.030976137  0.0547586029  0.036852638  3.445008e-02  0.0373142263
[49,]  0.031099015  0.0376380247  0.042629438  2.969833e-02  0.0132501602
[50,]  0.037671568  0.0164992497  0.037671568  4.095232e-02  0.0376715685
[51,]  0.010191824  0.0124199195  0.024492115  3.526452e-02  0.0385452703
[52,]  0.013193543  0.0198649795  0.010940362 -4.116437e-05  0.0034234425
[53,]  0.007599130  0.0104473757  0.006679889  6.679889e-03  0.0167674625
[54,]  0.014113586  0.0244294299  0.020494978  1.908597e-02  0.0152479477
[55,]  0.025621988  0.0331344320  0.017224218  2.409977e-02  0.0453518074
[56,]  0.023718768  0.0341738981  0.034162440  3.936403e-02  0.0302477030
[57,]  0.035133170  0.0381381602  0.047611513  2.439543e-02  0.0476115132
[58,]  0.015111599  0.0160308402  0.036350037  1.894962e-02  0.0264470494
[59,] -0.014692823 -0.0021239571 -0.009754801 -5.791050e-03 -0.0020474488
[60,] -0.037345437 -0.0600818573 -0.045646170 -4.159362e-02 -0.0529906954
[61,]  0.026106414  0.0415552682  0.042547951  4.401238e-02  0.0326449634
[62,]  0.027313380  0.0440577540  0.033258240  3.784665e-02  0.0258163271
            [,1]       [,2]       [,3]
 [1,] 0.05157169 0.05353564 0.04533419
 [2,] 0.03966726 0.05117484 0.04064836
 [3,] 0.05389255 0.05812013 0.04952909
 [4,] 0.05302011 0.04397099 0.04923552
 [5,] 0.03716264 0.04819529 0.04306025
 [6,] 0.04923552 0.05316247 0.03905337
 [7,] 0.05558391 0.04105221 0.03870503
 [8,] 0.04228085 0.02776720 0.02944016
 [9,] 0.04891122 0.06296640 0.05142512
[10,] 0.04064836 0.04848887 0.04968312

midasr documentation built on Feb. 23, 2021, 5:11 p.m.