Displaying 20 results from an estimated 10000 matches similar to: "Help with a Loop in function"
2009 Nov 02
1
AR Simulation with non-normal innovations - Correct
Dear Users,
I would like to simulate an AR(1) (y_t=ct1+y_t-1+e_t) model in R where the innovations are supposed to follow a t-GARCH(1,1) proccess.
By t-GARCH I want to mean that:
e_t=n_t*sqrt(h_t) and
h_t=ct2+a*(e_t)^2+b*h_t-1.
where n_t is a random variable with t-Student distribution.
If someone could give some guidelines, I can going developing the model.
I did it in matlab, but the loops
2009 Jan 20
0
arima.sim help
I am trying to simulate time series data for an ar(1) and ma(1) process. I want the error term to have either a t distribution with 1 degree of freedom or a normal distribution with mean=0 and sd=1. Here is my code:
error.model=function(n){rnorm(n,mean=0, sd=1)}
data<-arima.sim(model=list(ar=c(0.1)), n=1000,
n.start=200, start.innov=rnorm(200,mean=0, sd=1),
rand.gen=error.model )
data
2006 Feb 15
1
Generating random walks
Hello, here is another question, how do I generate
random walk models in R? Basically, I need an AR(1)
model with the phi^1 value equal to 1:
Yt = c + Yt-1 + E
where E is random white noise.
I tried using the arima.sim command:
arima.sim(list(ar=c(1)), n = 1000, rand.gen = rnorm)
but got this error since the model I am generating is
not stationary:
Error in arima.sim(list(ar = c(1)), n =
2005 Oct 10
1
using innov in arima.sim
Hello,
I have used the arima.sim function to generate a lot of time series, but to day I got som results that I didn't quite understand. Generating two time series z0 and z1 as
eps <- rnorm(n, sd=0.03)
z0 <- arima.sim(list(ar=c(0.9)), n=n, innov=eps)
and
z1 <- arima.sim(list(ar=c(0.9)), n=n, sd=0.03),
I would expect z0 and z1 to be qualitatively similar. However, with n=10 the
2012 Feb 10
3
Help needed please
I have coded a time series from simulated data:
simtimeseries <- arima.sim(n=1024,list(order=c(4,0,0),ar=c(2.7607, -3.8106, 2.6535, -0.9258),sd=sqrt(1)))
#show roots are outside unit circle
plot.ts(simtimeseries, xlab="", ylab="", main="Time Series of Simulated Data")
# Yule ----------------------------------------------------------------------------
q1 <-
2012 Oct 08
1
arima.sim
Hi,
I have been using arima.sim from the stats package recently, and I'm
wondering why I get different results when using what seem to be the
same parameters. For example, I've given examples of three different
ways to run arima.sim with what I believe are the same parameters.
It's my understanding from the R documentation that rnorm is the
default function for rand.gen if not
2007 Feb 21
0
GLS models - bootstrapping
Dear Lillian,
I tried to estimate parameters for time series regression using time
series bootstrapping as described on page 434 in Davison & Hinkley
(1997) - bootstrap methods and their application. This approach is based
on an AR process (ARIMA model) with a regression term (compare also with
page 414 in Venable & Ripley (2002) - modern applied statistics with S)
I rewrote the code
2010 Aug 19
1
How to include trend (drift term) in arima.sim
I have been trying to simulate from a time series with trend but I don't see
how to include the trend in the arima.sim() call. The following code
illustrates the problem:
# Begin demonstration program
x <- c(0.168766559, 0.186874000, 0.156710548, 0.151809531, 0.144638812,
0.142106888, 0.140961714, 0.134054659, 0.138722419, 0.134037018,
0.122829846, 0.120188714,
2008 Oct 24
0
unstable MA results in ARIMA?
Dear colleagues,
I am relatively new to R and time series and so I am experiencing
difficulties in interpreting the output of "arima" in MA models (but not
in AR models). I cannot make sense of the 1st innovations returned by
"arima".
In an AR(1) model I expect data[t]=phi1*data[t-1]+a[t] and in a MA(1)
model data[t]=a[t]+theta1*a[t-1]. My interpretation from R-help is
2004 May 24
1
Null model for arima.sim().
In some time series simulations I'm doing, I occasionally want the
model to be ``white noise'', i.e. no model at all. I thought it
would be nice if I could fit this into the arima.sim() context,
without making an exceptional case. I.e. one ***could*** do
something to the effect
if(length(model)==0) x <- rnorm(n) else x <- arima.sim(model,n)
but it would be more suave if one
2007 Jul 02
0
ARIMA prediction
Hi
This is my first post to this group, so apologies in advance if I get it wrong.
I would like to know how the prediction for arima models works in R. I
have a time series to which I fit an arima model, of varying AR and MA
orders. I then use the predict function to project it forward. I have
also written my own function to perform the prediction, but it gives
different answers to Arima.predict
2007 Aug 23
1
Estimate Intercept in ARIMA model
Hi, All,
This is my program
ts1.sim <- arima.sim(list(order = c(1,1,0), ar = c(0.7)), n = 200)
ts2.sim <- arima.sim(list(order = c(1,1,0), ar = c(0.5)), n = 200)
tdata<-ts(c(ts1.sim[-1],ts2.sim[-1]))
tre<-c(rep(0,200),rep(1,200))
gender<-rbinom(400,1,.5)
x<-matrix(0,2,400)
x[1,]<-tre
x[2,]<-gender
fit <- arima(tdata, c(1, 1, 0), method = "CSS",xreg=t(x))
2009 Sep 29
0
Incoherence between arima.sim and auto.arima
Hello,
I have a question about function arima.sim
I tried to somulate a AR(1) process, with no innovation, no error term.
I used this code:
library(forecast)
e=rnorm(100,mean=0,sd=0)
series=arima.sim(model=list(ar=0.75),n=100,innov=e)+20
Then I tried to applicate ti this series auto.arima function:
mod1<-auto.arima(series,stepwise=FALSE,trace=TRUE,ic='aicc')
The best model returned
2006 Mar 07
1
coding problems
hi,
I am trying to fit an ARIMA model to some time series data, I have used differencing to make the data stationary.
dailyibm is the data I am using, could someone please help out in identifying the coding as I can't seem to identify the problem
many thanks
> fit.ma <- arima.sim(dailyibm - mean(dailyibm), model=list(order=c(0,1,0)),n = 3333)
Error in inherits(x,
2009 Jul 21
0
Specifying initial values for arima.sim
Hi Everyone,
I'm having a problem with arima.sim. Namely specifying inital values
for the series.
If I generate a random walk
> vs = rnorm(100,0,1)
> xs = cumsum(vs)
and fit an ARIMA(1,0,0) to it
> xarima = arima(xs,order=c(1,0,0))
> xarima
Call:
arima(x = xs, order = c(1, 0, 0))
Coefficients:
ar1 intercept
0.9895 8.6341
s.e. 0.0106 6.1869
I should
2007 Jul 14
0
ts model challenge (transfer function)
Dear useRs,
I am trying to model a time series with a transfer function. I think
it can be put into the ARMA framework, and estimated with the 'arima'
function (and others have made similar comments on this list). I have
tried to do that, but the results have so far been disappointing.
Maybe I am trying to make 'arima' do something it can't...
The data are time series of
2007 Jan 16
2
ARIMA xreg and factors
I am using arima to develop a time series regression model, I am using arima
b/c I have autocorrelated errors. Several of my independent variables are
categorical and I have coded them as factors . When I run ARIMA I don't
get any warning or error message, but I do not seem to get estimates for all
the levels of the factor. Can/how does ARIMA handle factors in xreg?
here is some example
2007 Mar 07
1
Failure to run mcsamp() in package arm
Dear r-helpers,
I can run the examples on the mcsamp help page. For example:
****************************************
> M1 <- lmer (y1 ~ x + (1|group))
> (M1.sim <- mcsamp (M1))
fit using lmer,
3 chains, each with 1000 iterations (first 500 discarded)
n.sims = 1500 iterations saved
mean sd 2.5% 25% 50% 75% 97.5% Rhat n.eff
beta.(Intercept)
2008 Jul 12
1
Help with arima.sim
Hey,
as a bloddy beginner in R I want to simulate a Arima (2,1,0) process with R.
My problem is, that I don't know how to specify the AR.
For a ARIMA(1,1,0) I use the following syntax: S <-
arima.sim(list(order=c(1,1,0), ar=0.9), n=100).
I think it is a stupid question with an easy answer. But when I google
the only results are arima.sim for an ARIMA (1,1,0).
Regards,
Chris
--
2005 Oct 02
2
arima.sim bug?
Hi,
I am using the arima.sim function to generate some AR time series. However, the function does not seem to produce exactly the same time series when I specify the innov parameter. For example
> r <- rnorm(300)
> x <- arima.sim(300, model=list(order=c(1,0,0),ar=c(.96)), innov=r, n.start=10)
> y <- arima.sim(300, model=list(order=c(1,0,0),ar=c(.96)), innov=r, n.start=10)
>