Legacy Documentation

Time Series (2011)

This is documentation for an obsolete product.
Current products and services

Previous section-----Next section

1.4.2 Generating Time Series

Sometimes we may need to generate a time series {x1, x2, ... , xn} from a given process in order to explore it theoretically or gain intuition about it. The simplest time series is a sequence of independently and identically distributed (IID) random numbers. We can use the function
RandomSequence[,"""2", n]
to generate a sequence of n random numbers distributed according to the normal distribution with mean and variance 2.
In[19]:=
Out[19]=
It is usually a good idea to seed the random number generator using SeedRandom[seed] before generating any random numbers so the calculation can be repeated if necessary.
In[20]:=
In[21]:=
Out[21]=
Note that we have used SeedRandom so the above series can be reproduced if so desired. We reiterate that the covariance matrix must be a symmetric, positive definite matrix. Otherwise no random numbers will be generated.
In[22]:=
Out[22]=
Internally, RandomSequence uses RandomReal to generate a univariate random sequence of length n. The current default random number generator is used. Sequences generated prior to Version 6.0 of Mathematica can be obtained by including the option LegacySequence→True.
We can similarly generate univariate random sequences according to the distributions of our choice. Please consult the Mathematica documentation for distributions included with Mathematica.
To generate a time series of length n, {x1, x2, ... , xn}, according to one of the models defined in earlier sections, we can use the function
TimeSeries[model, n].
It generates the series by iterating
The noise {zt} is generated from the normal distribution with zero mean and variance or covariance specified in model. For models with p≠0, p random numbers from the same distribution as the noise are used as the initial values {x-p+1, x-p+2, ... , x0}. We can also generate time series with specified initial values of the series using
and with a specified noise sequence {z-q+1, z-q+2, ... , zn} using
Note that both the p initial values and the noise sequence are enclosed in lists. For an m-variate series each xi or zi is a list of m numbers.
Like RandomSequence, TimeSeries uses the current default random number generator. Series generated prior to Version 6.0 of Mathematica can be obtained by including the option LegacySequence→True.
In[23]:=
In[24]:=
Out[24]=
We can also generate a time series with a specified noise sequence.
In[25]:=
Out[25]=
In[26]:=
Out[26]=
In[27]:=
In[28]:=
Out[28]=