4
$\begingroup$

I need to simulate an ARIMA(24,1,24) and I need it to start in the value 201.9. I use this code:

AR=c(rep(0,15),-0.4153,0,-0.2756,0.0648,rep(0,4),0.4113)
MA=c(0.0333,rep(0,15),0.4086,0,-0.159,rep(0,4),-0.4373)
set.seed(201.9)
test=arima.sim(model=list(ar=AR,1,ma=MA),48,sd=sqrt(0.04114))

but the result is

> test
Time Series:
Start = 1 
End = 48 
Frequency = 1 
 [1] -0.27316579  0.20749619 -0.12835911  0.12214197 -0.22945806  0.13178123
 [7]  0.04573641  0.36200390 -0.46684265  0.29717346 -0.31135894  0.13539167
[13]  0.21997990 -0.35134322  0.49790011 -0.42154630  0.35056175  0.03470862
[19]  0.66058853 -0.08921610  0.29556006  0.08122176  0.38895428 -0.25651422
[25] -0.22049509 -0.06415654  0.07688333 -0.12579347  0.25334491  0.11758624
[31] -0.29212792  0.56738316 -0.58642879  0.06029231 -0.29947094  0.37453197
[37] -0.14767161 -0.47551637  0.27601816  0.04543016 -0.21988223 -0.04854361
[43]  0.42858816  0.31826853  0.34349185  0.03578720  0.02682161 -0.61197084

I need to see results like this for example:

[1] 205.6630 243.8738 233.7408 253.4030 243.6766 339.0593 356.5167 258.3706
 [9] 247.8154 213.7239 197.0198 177.9323 177.5526 169.4676 153.2032 169.8762
[17] 224.1862 233.1749 236.1136 228.4079 240.0980 233.0451 203.8956 202.9322
[25] 191.9604 232.1895 221.7581 244.5288 254.1557 269.4983 317.5880 297.0995
[33] 264.6354 235.3557 186.9068 191.8556 204.5835 181.4777 183.1193 181.4503
[41] 231.8501 241.2742 248.7449 243.2180 235.2816 234.1833 201.5701 204.0210

What can I do to make the correct simulation?

$\endgroup$
  • 1
    $\begingroup$ Do not ask people to email you about your problem. Any discussion about your issue should occur here, on this site, so that other users can read and understand what is going on, and can benefit as well. $\endgroup$ – 40XUserNotFound Oct 3 '15 at 4:49
  • $\begingroup$ This answer gives the analytical expressions for the burn-in observations in an AR(4) process where the first four observations are fixed to some desired values (the initial innovations are fixed to zeros). You could adapt this idea to your case. $\endgroup$ – javlacalle Oct 3 '15 at 17:25
  • 1
    $\begingroup$ The approach proposed by @RichardHardy may be more practical. An alternative to it can be based on this answer. Simulate a series that starts with the value 201.9, fit the ARIMA(24,1,24) model with fixed parameters and use simulate: x<-ts(c(201.9, rnorm(100))); AR<-c(rep(0,15),-0.4153,0,-0.2756,0.0648,rep(0,4),0.4113); MA<-c(0.0333,rep(0,15),0.4086,0,-0.159,rep(0,4),-0.4373); fit<-arima(x, order=c(24,1,24), fixed=c(AR,MA)); simulate(fit,future=FALSE) $\endgroup$ – javlacalle Oct 3 '15 at 17:26
  • $\begingroup$ @javlacalle, that could perhaps better fit as an answer rather than a comment. $\endgroup$ – Richard Hardy Oct 3 '15 at 17:36
  • $\begingroup$ @RichardHardy I think this question is a possible duplicate. I just wanted to draw the attention to those posts instead of duplicating the answers here. $\endgroup$ – javlacalle Oct 3 '15 at 17:48
3
$\begingroup$

You seem to be using the line set.seed(201.9) with the intention to make the first value of the simulated series equal to 201.9. However, this is not how the set.seed function works. The argument is used to "fix the randomness" (so that you could later replicate your results), not to set the first generated value. You can find detailed documentation of set.seed function here.

What you could do instead is, take the test series you have obtained so far and add 201.9-test[1] to it. Then you will have a series starting at 201.9 behaving as ARIMA(24,1,24) around the mean level of 201.9.

$\endgroup$
  • 1
    $\begingroup$ start.innov should somehow achieve that, I guess $\endgroup$ – Christoph Hanck Oct 3 '15 at 14:19
  • $\begingroup$ I thought so too, and I would like to see an example. I was however not able to find a way to do it easily enough. I think it might require solving for the initial values recursively so that the first value of the process would be 201.9, and then setting these initial values to achieve that. $\endgroup$ – Richard Hardy Oct 3 '15 at 16:55
2
$\begingroup$

Adding a constant say 201.9 to the first value will only inject a pulse at observation 1 which can easily be detected by eye or via Intervention Detection procedures http://www.unc.edu/~jbhill/tsay.pdf often are often ignored in introductory econometric texts/courses and will can seriously distort both descriptive statistics and simple inferential statistics like the AIC/BIC . The correct procedure is to take the first simulated value say s1 and compute the ratio 201.9/s1 and use that as a multiplier of each and every simulated value. In this way the first value will be identical to 201.9 and subsequent values will be proportional to the original simulated values. This does not obfuscate/cloud/change/modify the underlying ARIMA structure and does deliver the required objective. I have found that good simulation strategies can enable evaluation of automatic model detection schemes and is also very useful in pedagogy in general . I have also found that flawed simulation strategies can often lead to spurious conclusions about methodologies under test. Beware the simulation results as flawed simulation often (read: always) leads to bad conclusions. Always test your simulation strategy or revised data by submitting the simulated data to a comprehensive analysis for confirmation that the simulation has been conducted correctly.

$\endgroup$
  • 2
    $\begingroup$ Your suggestion would change the variance of the process. If that's fine, it's fine. If not, my approach helps avoiding this nuisance effect. What I suggested was adding a constant to a vector, which in R language will add the same constant to each element of the vector. In other words, it will not only be the first value but instead all of the values that will be shifted by the same amount. So then you get an ARIMA process with the desired variance but fluctuating around a new level of 201.9-test[1] instead of fluctuating around the level of zero. $\endgroup$ – Richard Hardy Oct 3 '15 at 16:53
  • $\begingroup$ Yes it changes the the variance of the series but it would also change the variance of the error process and the r-squared ( explanatory power ) of any model would be invariant. I (inadvertently) thought that you suggested just changing the first value . (..."with the intention to make the first value of the simulated series equal to 201.9") because you stated the first value. As you now correctly reflect you were suggesting changing all values not just the first value. $\endgroup$ – IrishStat Oct 3 '15 at 17:01
  • 1
    $\begingroup$ So your approach affects the variance, mine affects the mean. A follow up question, Could one preserve both the variance and the mean and still have the first value set to 201.9? I think for that to happen the initial values would need to be calculated recursively backward to ensure they yield the first value of 201.9. Then the process would start at this level and by contruction eventually revert to the specified mean. But this setting is perhaps not what the OP really wanted. $\endgroup$ – Richard Hardy Oct 3 '15 at 17:01
  • $\begingroup$ yes you are correct .... $\endgroup$ – IrishStat Oct 3 '15 at 17:03
  • $\begingroup$ dId you mean "add 201.9)" OR add 201.9 - first simulation value to all values ? $\endgroup$ – IrishStat Oct 3 '15 at 17:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.