this is the nav!
Workspace
Gino Sartor/

# Course Notes: ARIMA Models in R

0
Beta

Use this workspace to take notes, store code snippets, and build your own interactive cheatsheet!

Note that the data from the course is not yet added to this workspace. You will need to navigate to the course overview page, download any data you wish to use, and add it to the file browser.

```.mfe-app-workspace-jfrv3u{font-size:13px;line-height:20px;font-family:JetBrainsMonoNL,Menlo,Monaco,'Courier New',monospace;}```# Import any packages you want to use here
``````

### Stationarity

• nel trend = la media è costante
``````# Plot detrended y (trend stationary)
# se c'è un trend, la differenza tra un valore e il precedente dovrebbe essere detrended e quindi stazionaria
par(mfrow = c(2,1))
plot(y)
plot(diff(y)) # se trend lineare
plot(diff(log(y))) # se il trend è esponenziale``````

Any stationary ts can be represented as a linear combination of white noise

X(t) = W(t) + aW(t) + bW(t-1)+...

Questo modello si chiama ARMA Il codice successivo lo simula nelle sue 3 componenti: noise, moving average e autoregressive

``````# Generate and plot white noise
WN <- arima.sim(model = list(order = c(0, 0, 0)), n = 200)
plot(WN)

# Generate and plot an MA(1) with parameter .9 by filtering the noise
MA <- arima.sim(model = list(order = c(0, 0, 1), ma = .9), n = 200)
plot(MA)

# Generate and plot an AR(1) with parameters 1.5 and -.75
AR <- arima.sim(model = list(order = c(2, 0, 0), ar = c(1.5, -.75)), n = 200)
plot(AR)``````

``````library(astsa)