[R] simulation

2013-01-03 Thread Simone Gogna
]) plot(Pt) Rt_init_cond<-0 Rt<-Rt_init_cond*0 Rt[2]<- -a*Rt[1]+a*Et[1]+e[2] for(i in 2:(n)){ Rt[i]<- -a*Rt[i-1]+a*Et[i-1]+e[i] } Rt<-ts(Rt[(length(Rt)-n+1):length(Rt)]) plot(Rt) I don’t think the code above is correct, and I don’t even know if this is the approach

Re: [R] creating a function

2012-12-23 Thread Simone Gogna
agged values of Y_t+1 from Y_t to Y_t-n. Epsilon_t is, as You said a vector of random errors. Any suggestion is very appreciated. thanks and best regards, Simone From: Rui Barradas Sent: Saturday, December 22, 2012 8:29 PM To: Simone Gogna Cc: r-help@r-project.org Subject: Re: [R] creating a f

[R] creating a function

2012-12-22 Thread Simone Gogna
Dear R users, I’d like to create a function as: Y.t+1 = Y.t + (1\p)*summation(x(Y.t,Y.t-1,...)) + epsilon.t where x is a function of Y.t, Y.t-1 and so on, epsilon is a random error and p is a parameter. Do you think something of the following form might be appropriate? Y<-function(Y,p,x,epsi