#Experimentation with set.seed and arima.sim #set.seed sets the PRN seed. set.seed(101) rnorm(1) rnorm(1) set.seed(101) rnorm(1) #This experiment shows how set.seed starts the "cycle" all over again. #Two of the optional parameters of arima.sim are innov and start.innov. #They have default value NULL but they are very useful, in particualar #the parameter innov gives us a way to control the "sigma" parameter of #an ARIMA model set.seed(101) my.innov<-rnorm(500, sd=0.25) set.seed(101) my.start<-rnorm(500, sd=0.25) #Here we took our "burn-in" sequence to have the same innovations and same #number of innovations as our production sequence. This is uncommon, even #a little weird, but it is not against the law. #Now, lets simulate an ARIMA(2,0,3) of length 500 #First Specifiy the model; lets pick one with 5 parameters. #Recall we have already handled sigma with innov mymodel<-list( ar=c(0.1,0.1), ma=c(0.1, 0.1, 0.2) ) #There are several ways to specify the model. mysimulation<-arima.sim(model=mymodel, innov=my.innov, start.innov=my.start, n=500) #Note: n=500 was actually redundant here. #By the way, if you apply arima.mle to this simulated data, you are quite likely to #find a failure of convergence! #This is an irritation, which we will not belabor right now, but it is worth #keeping our eye on. arima.mle(mysimulation, model=list(order=c(2,0,3)))