From j@n@@nn@ert @ending from u@ntwerpen@be  Fri Oct  5 09:58:15 2018
From: j@n@@nn@ert @ending from u@ntwerpen@be (Annaert Jan)
Date: Fri, 5 Oct 2018 07:58:15 +0000
Subject: [Rd] 
 [R] Bug : Autocorrelation in sample drawn from stats::rnorm (hmh)
In-Reply-To: <f5169c3a-cd6b-1ba4-9701-4119f4123db3@gmx.fr>
References: <1607055752.4873464.1538697126419.ref@mail.yahoo.com>
 <1607055752.4873464.1538697126419@mail.yahoo.com>
 <f5169c3a-cd6b-1ba4-9701-4119f4123db3@gmx.fr>
Message-ID: <61E0376C-8813-4678-B4AF-12D57017624C@ua.ac.be>

On 05/10/2018, 09:45, "R-help on behalf of hmh" <r-help-bounces at r-project.org on behalf of hugomh at gmx.fr> wrote:

    Hi,
    
    Thanks William for this fast answer, and sorry for sending the 1st mail 
    to r-help instead to r-devel.
    
    
    I noticed that bug while I was simulating many small random walks using 
    c(0,cumsum(rnorm(10))). Then the negative auto-correlation was inducing 
    a muchsmaller space visited by the random walks than expected if there 
    would be no auto-correlation in the samples.
    
    
    The code I provided and you optimized was only provided to illustrated 
    and investigate that bug.
    
    
    It is really worrying that most of the R distributions are affected by 
    this bug !!!!
    
    What I did should have been one of the first check done for _*each*_ 
    distributions by the developers of these functions !
    
    
    And if as you suggested this is a "tolerated" _error_ of the algorithm, 
    I do think this is a bad choice, but any way, this should have been 
    mentioned in the documentations of the functions !!
    
    
    cheers,
    
    hugo
 
This is not a bug. You have simply rediscovered the finite-sample bias in the sample autocorrelation coefficient, known at least since
Kendall, M. G. (1954). Note on bias in the estimation of autocorrelation. Biometrika, 41(3-4), 403-404. 

The bias is approximately -1/T, with T sample size, which explains why it seems to disappear in the larger sample sizes you consider.

Jan



[Rd] [R] Bug : Autocorrelation in sample drawn from stats::rnorm (hmh)
Annaert Jan