[R] Simulating a time series with a given spectrum

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed May 27 18:15:14 CEST 2015

On 27/05/2015 16:54, Roy Mendelssohn - NOAA Federal wrote:
> Hi All:
> Is there a routine in R that allows me to simulate a time series that has a given spectrum?  I have looked at the R Time Series Task view, and have done a web search also, including an article to appear in the handbook of statistics on time series in R, but I don’t see anything offhand.  There are some that will simulate state-space models or for given covariances matrices, but for a variety of reasons I would prefer simulating series with a given spectrum.

It is relatively simple to do for series of lengths a power of two (and 
you can simulate a longer series to achieve this).  Use the spectrum 
values to simulate independent complex normals with uniform phase and 
variance proportional to the spectral density at the Fourier frequencies 
then use the inverse fft() to get the series.

You should be able to copy some code from boot::tsboot()'s 'scramble' 

> Thanks for any help.
> -Roy
> **********************
> "The contents of this message do not reflect any position of the U.S. Government or NOAA."
> **********************
> Roy Mendelssohn
> Supervisory Operations Research Analyst
> Environmental Research Division
> Southwest Fisheries Science Center
> ***Note new address and phone***
> 110 Shaffer Road
> Santa Cruz, CA 95060
> Phone: (831)-420-3666
> Fax: (831) 420-3980
> e-mail: Roy.Mendelssohn at noaa.gov www: http://www.pfeg.noaa.gov/

Brian D. Ripley,                  ripley at stats.ox.ac.uk
Emeritus Professor of Applied Statistics, University of Oxford
1 South Parks Road, Oxford OX1 3TG, UK

More information about the R-help mailing list