Simulating a Time series

Discussion in 'Scientific Statistics Math' started by ......, Aug 20, 2008.

  1. ......

    ...... Guest

    Hi,

    I want to simulate a double seasonal ARMA model in MATLAB using Monte
    Carlo methods. Can anyone point to some examples especially if they
    are done using MATLAB.

    regards
    Leo
     
    ......, Aug 20, 2008
    #1
    1. Advertisements

  2. ......

    Herman Rubin Guest

    Just simulate the ARMA process. I have not used
    MATLAB, so I cannot give the code. However, I'
    suggest you import good random numbers,as I am
    almost certain that MATLAB's generator is very
    poor indeed.
     
    Herman Rubin, Aug 21, 2008
    #2
    1. Advertisements

  3. On 21 Aug 2008 10:58:54 -0400, (Herman
    Rubin) wrote:

    snip
    Herman:

    For generating normal random numbers, Matlab defaults to Marsaglia's
    ziggurat method.

    Is that a bad thing?
    -Dick Startz
     
    Richard Startz, Aug 21, 2008
    #3
  4. Richard Startz a écrit :
    Usually the problem is not really the method to obtain normal random
    numbers from uniform random numbers, it's to obtain the uniform
    random numbers needed: in the past many programs have used poor
    methods. I thought Matlab had a good one now, though. But I
    had a look at output from the Matlab 4 rng - still proposed in recent
    versions with an option - and it didn't seem very good.

    Reading the Matlab function reference, here are the methods:

    'twister'
    Use the Mersenne Twister algorithm by Nishimura
    and Matsumoto (the default in MATLAB® Versions 7.4
    and later). This method generates double-precision
    values in the closed interval [2^(-53), 1-2^(-53)],
    with a period of (2^19937-1)/2.

    'state'
    Use a modified version of Marsaglia’s subtract
    with borrow algorithm (the default in MATLAB
    versions 5 through 7.3). This method can generate
    all the double-precision values in the closed interval
    [2^(-53), 1-2^(-53)]. It theoretically can generate
    over 2^1492 values before repeating itself.

    'seed'
    Use a multiplicative congruential algorithm (the
    default in MATLAB version 4). This method generates
    double-precision values in the closed interval
    [1/(2^31-1), 1-1/(2^31-1)], with a period of 2^31-2.
     
    Jean-Claude Arbaut, Aug 21, 2008
    #4
  5. ......

    aruzinsky Guest

    I want to take this opportunity to complain about Matlab users asking
    Matlab specific questions in generic technical forums. Matlab is a
    proprietary commercial product and their questions have the effect of
    advertising that commercial product and enriching its manufacturer
    whether intended or not. Matlab users have their own Usenet forum and
    they are morally remiss for asking Matlab specific questions outside
    those forums. Those Matlab users are as morally remiss as the people
    spamming Muslim proselytization. Both Matlab and the Muslim religion
    are equally irrelevant to numerical analysis.
     
    aruzinsky, Aug 21, 2008
    #5
  6. The current version of Matlab uses different random number generators
    for uniform and normal random numbers. I have no idea why though.
     
    Richard Startz, Aug 21, 2008
    #6
  7. Richard Startz a écrit :
    I'm not sure I understand what you mean: normal numbers are generated
    by ziggurat or polar method, but both need to use a uniform rng
    as input, and after reading matlab reference for rand and randn, I still
    don't see why they would be different.

    They say "The randn and rand generators each maintain their own
    internal state information. Initializing the state of one has no effect
    on the other."
    I seems to me that it implies they use the same rng, but with different
    internal state.
     
    Jean-Claude Arbaut, Aug 21, 2008
    #7
  8. The default for normals is the ziggurat method. The default for
    uniform is Mersenne Twister. Since Matlab supplies links to the
    scientific literature I suppose I could read that, I was just
    wondering if there was a simple explanation for the difference, or any
    reason to doubt the resulst for the current default for normals.
     
    Richard Startz, Aug 21, 2008
    #8
  9. Richard Startz a écrit :
    The Ziggurat method was designed for non-uniform random deviates:
    it's a kind of rejection method, and it _uses_ uniform random
    numbers as input. If you prefer, Ziggurat only transforms uniform
    random numbers into non-uniform ones, following a given distribution.

    The Box-Muller (or polar) method gives only normal random numbers,
    but it still uses a uniform rng as input

    Actually, most non-uniform rng use uniform rng and transform them
    in some way.

    Now, the Mersenne Twister generates *only* uniform (pseudo)random
    numbers: used "as is", or by a non-uniform rng.
    As far as I know, it's the best uniform rng to date, for
    non-cryptographic appllications.
     
    Jean-Claude Arbaut, Aug 21, 2008
    #9
  10. aruzinsky a écrit :
    I don't agree. Scientific software questions are also important here.
    Numerical analysis is not done with a pencil and a logarithmic table,
    these days. And I won't go for a war against non-free software: scilab
    is cool, matlab too. Why try to hide it ? Anyway, I'd bet most of those
    who come here have already had a taste of matlab. Take it as advertising
    or not, I don't care, but, you know, matlab is widely used in teaching,
    research, and industry. It's not a crime not sing everyday in praise
    of open source software. Please note I prefer oss, but I won't pretend
    I'm blind.

    I tried to have a look at the charter, but didn't find it. If you
    find more information in it let me know.
     
    Jean-Claude Arbaut, Aug 21, 2008
    #10
  11. On Thu, 21 Aug 2008 19:53:07 +0200, Jean-Claude Arbaut

    snip
    Thanks. Very helpful.
     
    Richard Startz, Aug 21, 2008
    #11
  12. ......

    Ray Koopman Guest

    The WELL generator is an improved Mersenne Twister. See
    http://www.iro.umontreal.ca/~panneton/WELLRNG.html
    http://www.iro.umontreal.ca/~lecuyer/myftp/papers/wellrng.pdf
     
    Ray Koopman, Aug 21, 2008
    #12
  13. Jean-Claude Arbaut, Aug 21, 2008
    #13
  14. ......

    aruzinsky Guest

    There are relevant differences between Matlab and commercial compilers
    of public domain programming languages such as C++. I can use Visual C
    ++ and ask questions about numerical analysis in C++ because it is not
    an endorsement of Microsoft. Also, C++ can be used as pseudocode to
    express an algorithm because it resembles pseudocode. The same is not
    true of Matlab.

    Furthermore, I have noticed a pattern among Matlab users asking
    questions in generic technical forums. On average, the questions from
    Matlab users are relatively stupid and not of general interest. It
    seems to me either stupid, selfish people gravitate to Matlab or
    Matlab makes people stupid and selfish. On that basis alone, I bet
    Matlab harms more than benefits society.

    For example, the OP did not put "Matlab" in the title of his post and
    thereby misrepresented his post as being of more general interest.
    So, I click on it to give a general answer, but NOOOOOOOOOOOO, the
    asshole wants to know how to do in Moronese (Matlab). Now, every non-
    user of Matlab who does a search on "Simulating a Time series" will
    also be jerked around by the OP. That chaos wouldn't exist without
    Matlab.
     
    aruzinsky, Aug 21, 2008
    #14
  15. aruzinsky a écrit :
    Wrong. Octave has almost the same language. And actually its language
    is perfect as pseudocode. And I have seen quite a few numerical
    analysis books with algorithms in matlab.

    Anyway, I don't care if it's 100% only commercial. It's useful, period.
    Your opinion. I find simulating an ARMA quite interesting indeed.
    And I find helping people on usenet extremely entertaining.
    An occasion to refresh my knowledge, and to learn many tricks
    and the existence of many good programs.
    Certainly not. I have had the occasion to work with it, and it
    deserves its reputation of a *good* software. No wonder why
    it's so widely used.
    It actually is. A pseudocode would be enough. That the OP gave the
    language may only be helpful to somebody trying to help him.
    And would I answer, I would probably use Matlab pseudocode or
    something equivalent (e.g. scilab).
    This has nothing to do with Matlab or with commercial software in
    general. It may just happen that this guy is a student and a newbie
    in numerical analysis. Usenet is not only for experts you know.

    For a bit of nostalgy, have a look here ;-)
    http://ftp.funet.fi/pub/sci/math/misc/programs/matlab/
     
    Jean-Claude Arbaut, Aug 21, 2008
    #15
  16. ......

    aruzinsky Guest

    For everyone drawn to this post who doesn't use Matlab, the general
    form of an ARMA(p,q) time series is

    Xt = a1*Xt-1 + a2*Xt-2 + ... + ap*Xt-p + Et + b1*Et-1 + b2*Et-2 + ...
    bq*Et-q

    where {Et} is usually i.i.d. of zero mean but variations exist.


    You can implement this in matrix form:

    Xt = aTx + bTe + Et

    Of course, {Et} are pseudorandom numbers of zero mean. You may or may
    not want {Et} to be normally distributed depending on the purpose of
    the series. Assuming the transfer function has all poles inside the
    unit circle the following will generate a close approximation to a
    stationary series. Intialize x = 0, e = 0 and iterate. At each
    iteration, shift the elements of vectors x and e downward and replace
    the top elements with Xt and Et from the previous iteration. You
    should DISCARD the first several hundred {Xt} because they are NOT
    sufficiently stationary for many intents and purposes. To play it
    safe, discard the first 10000 iterates which is quick enough on
    today's PCs.
     
    aruzinsky, Aug 21, 2008
    #16
  17. ......

    aruzinsky Guest

    Do you think it is a coincidence that the only person to answer the
    question, namely me, never used Matlab? I don't. I suspect Matlab
    made you too dumb to answer the question.
     
    aruzinsky, Aug 22, 2008
    #17
  18. aruzinsky a écrit :
    Are you a troll ?
     
    Jean-Claude Arbaut, Aug 22, 2008
    #18
  19. ......

    aruzinsky Guest

    No, because I just made a positive contribution to society and trolls
    don't do that. Are you projecting?
     
    aruzinsky, Aug 22, 2008
    #19
  20. aruzinsky a écrit :
    Mmm... it's true.
    Projecting ? What do you mean ?
     
    Jean-Claude Arbaut, Aug 22, 2008
    #20
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.