[R] R 3.1.2 : arima.sim(model=list(ma=0.5), n=250, innov=rnorm(250, mean=0, sd=0.1)) versus arima.sim(model=list(ma=0.5), n=250, mean=0, sd=0.1) => only the first element is not identical !

Fabien Tarrade fabien.tarrade at gmail.com
Sat Jul 11 09:46:16 CEST 2015


Dear all,

When doing a DataCamp tutorial with R I find the following observation 
that using 2 different syntax for "arima.sim" give different answer for 
the first element

If I use the the function using the list of argument describe in the 
help manual :
arima.sim(model=list(ma=0.5),n=250,innov=rnorm(250,mean=0,sd=0.1))

or if I use the following syntax use in a DataCamp example :

arima.sim(model=list(ma=0.5), n=250, mean=0, sd=0.1) it is accepted by 
DataCamp

I don't find exactly the same results. The reason is that even if the 
seed is the same in both cases the first element is not identical while 
it should be (it doesn't mean that the results is wrong, maybe for the 
first element the seed is not propagated correctly)

here the results of the difference using the same seed (only the first 
element is different using the 2 different syntaxes) :

   [1] -0.252214  0.000000  0.000000  0.000000  0.000000  0.000000 
0.000000  0.000000  0.000000  0.000000
  [11]  0.000000  0.000000  0.000000  0.000000  0.000000 0.000000  
0.000000  0.000000  0.000000  0.000000


here the code to reproduce this feature :

set.seed(123);
test1 <- 0.05 + 
arima.sim(model=list(ma=0.5),n=250,innov=rnorm(250,mean=0,sd=0.1))
set.seed(123);
test2 <- 0.05 + arima.sim(model=list(ma=0.5), n=250, mean=0, sd=0.1)

test1-test2

I am using R 3.1.2 GUI 1.65 Mavericks build (6833) on Mac (I guess arima 
come with stats which is included in R (?))
The DataCamp team ask me to report to you about this observation on this 
mailing list. If you want me to fill a bug report some R bug tracking 
system, let me know

Please tell me if this is the wrong list and which other information do 
you need from R and how to get then (compiler, version of some R 
packages ...)


Hope this help
Thanks
Cheers
Fabien
-- 
Dr Fabien Tarrade

Quantitative Analyst - Data Scientist - Researcher

Senior data analyst specialised in the modelling, processing and 
statistical treatment of data.
PhD in Physics, 10 years of experience as researcher at the forefront of 
international scientific research.
Fascinated by finance and data modelling.

Geneva, Switzerland

Email : contact at fabien-tarrade.eu <mailto:contact at fabien-tarrade.eu>
Phone : www.fabien-tarrade.eu <http://www.fabien-tarrade.eu>
Phone : +33 (0)6 14 78 70 90

LinkedIn <http://ch.linkedin.com/in/fabientarrade/> Twitter 
<https://twitter.com/fabtar> Google 
<https://plus.google.com/+FabienTarradeProfile/posts> Facebook 
<https://www.facebook.com/fabien.tarrade.eu> Google 
<skype:fabtarhiggs?call> Xing <https://www.xing.com/profile/Fabien_Tarrade>


More information about the R-help mailing list