[R] Simulate an AR(1) process via distributions? (without specifying a model specification)

Pedro.Rodriguez at sungard.com Pedro.Rodriguez at sungard.com
Wed Nov 28 20:05:26 CET 2007

Thanks Prof. Ripley.

My apologies for not including the code.

Below I illustrate my point using the GLD package. 

Thank you very much for your time.

Kind Regards,

Pedro N. Rodriguez 

# Code begins

# Simulate an ar(1) process  
# x = 0.05 + 0.64*x(t-1) + e

# Create the vector x
	x	<- vector(length=1000)

#simulate the own risk
	e	<- rnorm(1000)

#Set the coefficient
	beta 	<- 1.50

# set an initial value
	x[1] 	<- 5

#Fill the vector x
	for(i in 2:length(x))
		x[i]	<- 0.05 + beta*x[i-1] + e[i] 

#Check the AR(1) 
	simulated_data_ar <- arima(x,order=c(1,0,0))

#Using the G Lambda Distribution to fit the distribution. 
	resul1		<- starship(x,optim.method="Nelder-Mead") 
	lambdas1	<- resul1$lambda

#Plot the Distribution

#Random Deviates from GLD
	x_sim		<-

#Fit an AR(1)
	gld_simulated	<- arima(x_sim,order=c(1,0,0))

#Code ends

-----Original Message-----
From: Prof Brian Ripley [mailto:ripley at stats.ox.ac.uk] 
Sent: Wednesday, November 28, 2007 11:37 AM
To: Rodriguez, Pedro
Cc: r-help at stat.math.ethz.ch
Subject: Re: [R] Simulate an AR(1) process via distributions? (without
specifying a model specification)

On Wed, 28 Nov 2007, Pedro.Rodriguez at sungard.com wrote:

> Is it possible to simulate an AR(1) process via a distribution?

Any distribution *of errors*, yes.  Of the process values, not in

> I have simulated an AR(1) process the usual way (that is, using a
> specification and using the random deviates in the error), and used
> generated time series to estimate 3- and 4-parameter distributions
> instance, GLD). However, the random deviates generated from these
> distributions do not follow the specified AR process.

How do you know that?  Please give us the reproducible example we asked 
for (in the posting guide, at the bottom of every message), and we
be able to explain it to you.

Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

More information about the R-help mailing list