Pedro.Rodriguez at sungard.com
2007-Nov-28 15:47 UTC
[R] Simulate an AR(1) process via distributions? (without specifying a model specification)
Dear All, Is it possible to simulate an AR(1) process via a distribution? I have simulated an AR(1) process the usual way (that is, using a model specification and using the random deviates in the error), and used the generated time series to estimate 3- and 4-parameter distributions (for instance, GLD). However, the random deviates generated from these distributions do not follow the specified AR process. Any comment and feedback will be more than welcome. Thanks for your time. Pedro N. Rodriguez [[alternative HTML version deleted]]
Prof Brian Ripley
2007-Nov-28 16:36 UTC
[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 general.> I have simulated an AR(1) process the usual way (that is, using a model > specification and using the random deviates in the error), and used the > generated time series to estimate 3- and 4-parameter distributions (for > 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 should 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
Pedro.Rodriguez at sungard.com
2007-Nov-28 19:05 UTC
[R] Simulate an AR(1) process via distributions? (without specifying a model specification)
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)) simulated_data_ar #Using the G Lambda Distribution to fit the distribution. library(gld) resul1 <- starship(x,optim.method="Nelder-Mead") lambdas1 <- resul1$lambda #Plot the Distribution plotgld(lambdas1[1],lambdas1[2],lambdas1[3],lambdas1[4]) #Random Deviates from GLD x_sim <- rgl(1000,lambdas1[1],lambdas1[2],lambdas1[3],lambdas1[4]) #Fit an AR(1) gld_simulated <- arima(x_sim,order=c(1,0,0)) gld_simulated #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 general.> I have simulated an AR(1) process the usual way (that is, using amodel> specification and using the random deviates in the error), and usedthe> generated time series to estimate 3- and 4-parameter distributions(for> 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 should 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
Matthias Kohl
2007-Nov-29 07:34 UTC
[R] Simulate an AR(1) process via distributions? (without specifying a model specification)
Dear Pedro, you might be interested in the demo "StationaryRegressorDistr" of package "distr". library(distr) demo("StationaryRegressorDistr") hth, Matthias Pedro.Rodriguez at sungard.com wrote:> 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)) > simulated_data_ar > > #Using the G Lambda Distribution to fit the distribution. > library(gld) > resul1 <- starship(x,optim.method="Nelder-Mead") > lambdas1 <- resul1$lambda > > #Plot the Distribution > plotgld(lambdas1[1],lambdas1[2],lambdas1[3],lambdas1[4]) > > #Random Deviates from GLD > x_sim <- > rgl(1000,lambdas1[1],lambdas1[2],lambdas1[3],lambdas1[4]) > > #Fit an AR(1) > gld_simulated <- arima(x_sim,order=c(1,0,0)) > gld_simulated > > #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 > general. > > >> I have simulated an AR(1) process the usual way (that is, using a >> > model > >> specification and using the random deviates in the error), and used >> > the > >> generated time series to estimate 3- and 4-parameter distributions >> > (for > >> 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 > should > be able to explain it to you. > >