R/ARMA.R

Defines functions ARMA

Documented in ARMA

ARMA <- function(n,a,b){
  p<-length(a)
  q<-length(b)
  ns<-n+max(p,q)
  X<-c(1:ns)
  E<-c(1:ns)
  pm<-max(p,q)
  X[1]<-rnorm(1)
  for(i in 2:pm){
    X[i]<-X[i-1]+rnorm(1)}
  for(i in 1:ns){
    E[i]<-rnorm(1)
  }
  for(i in (pm+1):ns){                        
    for(j in 1:p){
      ai<-a[j]*X[i-j]
    }
    for(j in 1:q){
      ei<-b[j]*E[i-j]
    }
    X[i]<-ai+ei+E[i]
  }
  return(X)
}

Try the mistat package in your browser

Any scripts or data that you put into this service are public.

mistat documentation built on March 7, 2023, 6:43 p.m.