ComenzarEmpieza gratis

Estimate the random walk model

For a given time series y we can fit the random walk model with a drift by first differencing the data, then fitting the white noise (WN) model to the differenced data using the arima() command with the order = c(0, 0, 0)) argument.

The arima() command displays information or output about the fitted model. Under the Coefficients: heading is the estimated drift variable, named the intercept. Its approximate standard error (or s.e.) is provided directly below it. The variance of the WN part of the model is also estimated under the label sigma^2.

Este ejercicio forma parte del curso

Time Series Analysis in R

Ver curso

Instrucciones del ejercicio

  • The time series random_walk has already been loaded, and is shown in the adjoining figure. Use diff() to generate the first difference of the data. Save this to rw_diff.
  • Use ts.plot() to plot your differenced data
  • Use arima() to fit the WN model for the differenced data. To do so, set the x argument to rw_diff and set the order argument to c(0, 0, 0). Store the model in model_wn.
  • Store the intercept value of model_wn in int_wn. You can obtain this value using model_wn$coef.
  • Use ts.plot() to reproduce your original plot of random_walk.
  • Add the estimated time trend to the adjoining plot with the function abline(). You can use int_wn as the second argument.

Ejercicio interactivo práctico

Prueba este ejercicio completando el código de muestra.

# Difference your random_walk data
rw_diff <- 

# Plot rw_diff


# Now fit the WN model to the differenced data
model_wn <-

# Store the value of the estimated time trend (intercept)
int_wn <- 

# Plot the original random_walk data


# Use abline(0, ...) to add time trend to the figure

Editar y ejecutar código