Question

TIME SERIES ANALYSIS IN R Simulate time series of length 100 from an AR(1) model with...

TIME SERIES ANALYSIS IN R

Simulate time series of length 100 from an AR(1) model with α equal to 0.9.

Estimate the parameter of the model, make prediction for 1 to 10 steps ahead, and make a time plot

Homework Answers

Answer #1

A time series is a sequence of measurements of the same variable(s) made over time. Usually the measurements are made at evenly spaced times - for example, monthly or yearly. Let us first consider the problem in which we have a y-variable measured as a time series. As an example, we might have y a measure of global temperature, with measurements observed each year. To emphasize that we have measured values over time, we use "t" as a subscript rather than the usual "i," i.e., means measured in time period . An autoregressive model is when a value from a time series is regressed on previous values from that same time series. for example, on .

In this regression model, the response variable in the previous time period has become the predictor and the errors have our usual assumptions about errors in a simple linear regression model. The order of an autoregression is the number of immediately preceding values in the series that are used to predict the value at the present time. So, the preceding model is a first-order autoregression, written as AR(1).

Here the model is given by,

where ~ White Noise(0,1) and .

The R-Code is obtained as:

set.seed(123)
ts_AR = arima.sim(n=100, list(ar=c(0.9)))

#1. Estimate parameters with arima()
model_AR = arima(ts_AR, order=c(1,0,0))
model_AR

Call:
arima(x = ts_AR, order = c(1, 0, 0))

Coefficients:
ar1 intercept
0.8781 -0.3569
s.e. 0.0456 0.7220

sigma^2 estimated as 0.8847: log likelihood = -136.5, aic = 279.01

#2. Simulating the time series of length 100
arima.sim(model=as.list(coef(model_AR)), n=100)
Time Series:
Start = 1
End = 100
Frequency = 1
-0.45510124 -0.99424924 0.77784065 0.62900670 0.67158650 0.83341871 1.96431473 1.20883364 0.06898980 1.73627803 1.08349143 0.22836590 -1.03574122 -2.19421734 -2.50075226 -1.57796639 -0.27579042 0.46541219 0.04502890 0.09929056 -0.61740777 -1.25937420 -0.22122696 -1.20985566 0.89289957 0.69375039 0.82373259 -0.01519440 -0.58773114 -1.83311264 -1.79261212 -1.15514015 -0.69004346 -1.38747514 -2.00698699 -2.26456742 -0.49249369 -1.56977053 -1.55749324 0.53470108 0.36855503 -1.03620639 -1.57467952 -0.89729233 -1.16353021 -1.58359162 -1.73449540 -1.43259265 0.34052531 0.21045583 1.26560427 1.74210230 1.41612914 -0.28937542 -0.77522269 -1.17060641 -0.98077455 0.43896421 2.67854076 3.89965230 3.29119866 1.13352895 0.60659079 0.62186469 1.39108275 2.18406089 2.60216967 0.88973417 1.63093343 0.98559259 1.04026797 0.98802780 1.29577043 1.16251257 -0.64665345 0.16865880 0.53412867 0.20337566 0.29673206 0.39460401 0.56752782 2.13920180 1.65941834 1.62522826 2.59552387 3.33335376 4.07233655 2.99851854 4.63553179 4.13723853 5.49982989 3.47858952 3.07559097 3.95064222 2.75388253 1.66554114 0.52400071 -0.59237953 -0.95733787 -0.50947515

#3. Making Prediction for 1 to 10 steps ahead

library(forecast)
forecast(model_AR)
Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
101 -0.9998720 -2.205265 0.2055213 -2.843362 0.843618
102 -0.9215046 -2.525669 0.6826601 -3.374863 1.531854
103 -0.8526888 -2.706671 1.0012934 -3.688110 1.982732
104 -0.7922606 -2.817945 1.2334241 -3.890278 2.305757
105 -0.7391975 -2.887932 1.4095365 -4.025403 2.547008
106 -0.6926019 -2.931605 1.5464012 -4.116862 2.731658
107 -0.6516856 -2.957883 1.6545116 -4.178710 2.875339
108 -0.6157563 -2.972458 1.7409457 -4.220021 2.988508
109 -0.5842062 -2.979125 1.8107123 -4.246918 3.078506
110 -0.5565015 -2.980477 1.8674740 -4.263652 3.150649

#4.) Making the Time Plot

library(ggplot2)
autoplot(forecast(model_AR))

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Using R statistical software (a) Generate n = 100 observations from following time series model xt...
Using R statistical software (a) Generate n = 100 observations from following time series model xt =2cos(2πt/4)+ωt, where ωt is i.i.d N(0,1). (b) Apply the moving average to xt and get time series yt, such that yt = (xt + xt−1 + xt−2 + xt−3)/4. [hint: Use filter(x,rep(1/4,4)),sides=1] (c) Plot xt as a line and superimpose yt as a dashed line. (d) Describe the relationship between xt and yt.
1. General features of economic time series: trends, cycles, seasonality. 2. Simple linear regression model and...
1. General features of economic time series: trends, cycles, seasonality. 2. Simple linear regression model and multiple regression model: dependent variable, regressor, error term; fitted value, residuals; interpretation. 3. Population VS sample: a sample is a subset of a population. 4. Estimator VS estimate. 5. For what kind of models can we use OLS? 6. R-squared VS Adjusted R-squared. 7. Model selection criteria: R-squared/Adjusted R-squared; residual variance; AIC, BIC. 8. Hypothesis testing: p-value, confidence interval (CI), (null hypothesis , significance...
In time series analysis, how do you decide on the lag length p and q in...
In time series analysis, how do you decide on the lag length p and q in the ARMA(p,q) model?
To use R/Rstudio do it (a) Simulate a sample of size n = 30 from N(1,32),...
To use R/Rstudio do it (a) Simulate a sample of size n = 30 from N(1,32), and calculate the sample variance. (b) Plot the histogram of your simulated sample in part (a) with option breaks=10. (c) Repeat (a) 100 times using a for loop, so you will have 100 sample variances. Plot the histogram of the 100 sample variances. (d) Calculate the mean and the variance of the 100 sample variances in part (c). Is the mean close to 9?
The following time series shows the sales of a particular product over the past 12 months....
The following time series shows the sales of a particular product over the past 12 months. If required, round your answer to two decimal places. Click on the datafile logo to reference the data. Month Sales Month Sales 1 105 7 145 2 135 8 140 3 120 9 100 4 105 10 80 5 90 11 100 6 120 12 110 (a) Choose the correct time series plot. (i) (ii) (iii) (iv) - Select your answer -Plot (i)Plot (ii)Plot...
R Simulation: For n = 10, simulate a random sample of size n from N(µ,σ2), where...
R Simulation: For n = 10, simulate a random sample of size n from N(µ,σ2), where µ = 1 and σ2 = 2; compute the sample mean. Repeat the above simulation 500 times, plot the histogram of the 500 sample means (does it mean that I can just use hist() method instead of plot() method). Now repeat the 500 simulations for n = 1,000. Compare these two sets of results with different sample sizes, and discuss it in the context...
Consider the following time series data. Month 1 2 3 4 5 6 7 Value 24...
Consider the following time series data. Month 1 2 3 4 5 6 7 Value 24 13 20 12 19 23 15 (a) Construct a time series plot. A time series plot contains a series of 7 points connected by line segments. The horizontal axis ranges from 0 to 8 and is labeled: Month. The vertical axis ranges from 0 to 30 and is labeled: Time Series Value. The points are plotted from left to right at regular increments of...
Consider the following time series. t 1 2 3 4 5 yt 5 10 10 15...
Consider the following time series. t 1 2 3 4 5 yt 5 10 10 15 14 (a) Choose the correct time series plot. (i) (ii) (iii) (iv) - Select your answer -Plot (i)Plot (ii)Plot (iii)Plot (iv)Item 1 What type of pattern exists in the data? - Select your answer -Positive trend patternHorizontal stationary patternVertical stationary patternNegative trend patternItem 2 (b) Use simple linear regression analysis to find the parameters for the line that minimizes MSE for this time series....
Model Summary Model R R Square Adjusted R Square      Std. Error of the Estimate 1...
Model Summary Model R R Square Adjusted R Square      Std. Error of the Estimate 1 .816 .666 .629 1.23721 a. Predictors: (Constant),x         ANOVA     Model Sum of Squares df Mean Square F                       Sig Regression Residual Total 27.500 13.776 41.276 1 9 10 27.500 1.531 17.966                 .002b                    a. Dependent Variable: Y                    b. Predictors: (Constant), X Coefficients Model Understand Coefficients B               Std Error Standardized Coefficients      Beta t Sig 1 (Constant)        x 3.001             1.125 .500                 .118 .816 2.667...
Time series are particularly useful to track variables such as revenues, costs, and profits over time....
Time series are particularly useful to track variables such as revenues, costs, and profits over time. Time series models help evaluate performance and make predictions. Consider the following and respond in a minimum of 175 words: Time series decomposition seeks to separate the time series (Y) into 4 components: trend (T), cycle (C), seasonal (S), and irregular (I). What is the difference between these components? The model can be additive or multiplicative.When we do use an additive model? When do...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT