Skip to content

creating a function

5 messages · Rui Barradas, Simone Gogna, Jeff Newmiller

#
Hello,

If I understand it correctly, a simple change to my previous code will 
do. I have also change the name of function 'x' to 'FUN', to make it 
more readable.

Yfun <- function(Y, p, FUN, epsilon){
     for (i in 2:length(Y)) {
         Y[i] <- Y[i-1] + (1/p)*sum(FUN(Y[1:(i-1)])) + epsilon[i]
     }
     Y
}


Hope this helps,

Rui Barradas
Em 23-12-2012 08:39, Simone Gogna escreveu:
#
Sounds like you want to simulate an ARIMA model. Why don't you read up on that topic using RSiteSearch() and then perhaps rephrase your question?
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.
Simone Gogna <singletonthebest at msn.com> wrote: