Homework 5For this homework install the updated simts package as well as the expsmooth, quantmod and pageviews Rpackages from CRAN.Question 1Suppose we collect a time series data X = (X1, . . . , XT ).(a) According to the following R outputs, please write the estimated AR(1) model for the data X. What isthe estimation for the variance of withe noise?> fit.ML = estimate(AR(1),X, demean = FALSE)> fit.MLFitted model: AR(1)Estimated parameters:Call:arima(x = as.numeric(Xt), order = c(p, intergrated, q), seasonal = list(order = c(P,seasonal_intergrated, Q), period = s), include.mean = demean, method = meth)Coefficients:ar10.97s.e. 0.04sigma^2 estimated as 0.8929: log likelihood = -137.17, aic = 278.34(b) Please give out the 95 percent confidence interval for φ(the 97.5 percent quantile is 1.96).Is there anydrawback of this confidence interval?Any method to avoid this issue? Please state in detail.(c)Now we use AIC and BIC to select the model from a candidates pool. Model 1 has AIC=246.34 andBIC=268.64. Model 2 has AIC=256.45 and BIC=264.26.If the sets of candidate models (i.e. model 1 and model 2 we are considering) do not include the true model.Which information criteria we should use? Which model we should select? If the sets of candidate models(i.e. model 1 and model 2 we are considering) include the true model. Which information criteria we shoulduse? Which model we should select?(d)After selecting the model, we have the following R outputs.Based on this estimated model, if we know that XT −4 = 1, XT −3 = 1.3, XT −2 = 0.8, XT −1 = 1 and XT = 0.6,please give one day ahead prediction XTT +1 and two day ahead prediction XTT +2.Show the details of your work.Fitted model: AR(2)Estimated parameters:Call:arima(x = as.numeric(Xt), order = c(p, intergrated, q), seasonal = list(order = c(P,seasonal_intergrated, Q), period = s), include.mean = demean, method = meth)Coefficients:1ar1 ar2-0.3 0.6s.e. 0.0804 0.0819sigma^2 estimated as 0.9282: log likelihood = -138.97, aic = 246.34Question 2The data hospital contains monthly patient counts for 767 hospitals from January 2000 to December 2007.Focus on the eighth hospital (i.e. hospital[, 8]):1. Comment on the plot of the time series: does it appear to be stationary?2. If not stationary, use a linear regression to remove possible trends and/or seasonalities.3. Perform a diagnostic analysis on the residuals. Please state the purpuse of six graphs one by one indetail. does there appear to be dependence between lags?4. If there appears to be dependence in the residuals, propose and estimate a time series model for them.Justify the model.Question 3Using the quantmod library, download the stock prices of Microsoft from January 1st, 2000 (use the symbol“MSFT” within the getSymbols() function).1. Comment on the plot of the time series: does it appear to be stationary? If not, suggest how to make itstationary.2. To obtain the stock returns we need to take a first difference of the stock prices: does this time seriesappear to be stationary?3. Analyse the ACF and PACF plots of the returns: does there appear to be dependence?4. Analyse the ACF and PACF plots of the absolute value of the returns: does there appear to bedependence? Discuss.5. Propose and estimate a time series model for the returns and for the absolute returns. Justify themodels.Question 4Consider the utility data that contains hourly utility demand in the Midwest from January 1st 2003 toMay 7th 2003. Suppose you’re an analyst for the energy company:1. Apply linear regression (or another method) on time-related variables (e.g. hours, days, months) toobtain stationary residuals.2. Remove the last 24 hours (observations) from the residuals:a) Suggest and estimate a time series model for the first 3000 observations.b) Deliver point forecasts and 95% confidence intervals for the next 24 hours.c) Based on the point forecasts you obtained from the previous question, compute the MedianAbsolute Prediction Error (MAPE) of your point forecasts defined asMAP E = median are the j-ahead point forecasts and Xt+j are the j-ahead realizations representing theremoved 24 hours.2d) Based on the confidence intervals computed in question 3b, compute the empirical coverage ofyour confidence intervals (i.e. the percentage of times your confidence intervals contain the actualcorresponding future realization). Is it close to 95% ? If not, explain possible reasons why.Question 5Using the ukcars data representing the quarterly production of cars in the UK (in thousands) from the firstquarter of 1977 to the first quarter of 2005, do the following:1. Check if the time series is stationary and, if not, perform a linear regression to make the residualsstationary (use time and quarters as covariates).2. Estimate an AR(8) for the residuals using the MLE and give the parameters estimatesa) Give the parameter confidence intervals using their asymptotic distribution.b) Give the parameter confidence intervals using parametric bootstrap (B = 500)Question 6Consider the following code:set.seed(2)Xt = gen_gts(n = 200, AR(phi = c(0.75, 0.2), sigma2 = 1))B = 5000mat = matrix(0,B,52)mat[,1] = rep(Xt[199], B)mat[,2] = rep(Xt[200], B)for (i in 1:B){for (j in 3:52){mat[i,j] = 0.75*mat[i,(j-1)] + 0.2*mat[i,(j-2)] + rnorm(1)R留学生作业代做、代写data课程作业、代做R编程设计作业 调试Matlab程序|代做数据库SQL}}1. Explain what this code is doing.2. Change the code to obtain only point forecasts for the next 10 observations (i.e. 201 to 210).3. Use this code to deliver 95% confidence intervals for the next 10 observations (i.e. 201 to 210).4. Modify the code in order to obtain point forecasts and 95% confidence intervals for the next 20observations of following time series:Yt = gen_gts(n = 100, AR(phi = c(0.8), sigma2 = 0.5))Question 7Using the article_pageviews() function in the pageviews package, download the number of views for thearticle on “Cheese” (Cheese) from August 1st to September 30th (2018).1. Comment on the plot of this time series.2. Comment on the ACF and PACF plots of the time series.3. Use the robacf() function in the robcor package: do you notice a difference with the standard ACF?Discuss.34. Use the estimate() function to estimate the φ parameter of an AR(1) model using the MLE and theRGMWM: comment on the two estimates of φ.5. Adapting the code from Question 5, use the RGMWM estimates to deliver point forecasts and confidenceintervals for the next 28 days (October 1st to October 28th):a) Compute the MAPE for your point forecasts.b) Compute the empirical coverage of your confidence intervals.Question 8Consider the Ljung-Box statistic defined as:Qh = T(T + 2)X,where ρˆj is the estimated autocorrelation on a given time series. Show that, as T → ∞,meaning that the statistic tends towards a Chi-square distribution with h degrees of freedom.Question 9Please check the following models satisfy the conditions of causal and invertible ARMA models. (check theparamertric redundancy firstly)1. Xt − 1.5Xt−1 + 0.5Xt−2 = Wt − 1.8Wt−1 + 0.8Wt−22. Xt − 1.1Xt−1 + 0.28Xt−2 = Wt − 0.7Wt−1Question 10Consider the causal model:Xt = φXt−1 + Wt, t = 1, . . . , T,where Wt are i.d.d N(0, 1).1. Derive the conditional MLE for φ, say φˆ.2. Please find the theretical PACF values of Xt.3. From R output, we have φˆ = 0.94 and the standard error of φˆ is 0.05. please give our 95 percentageconfidence interval. Is this result reasonable or not? If we have X8 = 10, Please give the best linearprediction of X10.4. If we don’t have model assumptions on a series of observations: Y1, . . . , YN .. Now using the AICprincipal to select the model. If we have model 1 with AIC=275 and Model 2 with AIC=276. Whichmodel we shall use and explain the reason.5. Why is the property of stationay important when working with a time series?4Question 11Consider the theoretical ACF and PCAF are presented in the figure below. Using the figure below:1. Propose a reasonable model for this time series. Justify your answer.2. Propose a value of the model’s parameters. Justify your answer.## Warning: package simts was built under R version 3.5.2LagsACFTheoretical ACF plot0 5 10 15 20−0.5 0.0 0.5 1.0LagsPACFTheoretical PACF plot5 10 15 20−0.5 −0.4 −0.3 −0.2 −0.1 0.0Question 12(Adapted from Cryer & Chan Exercise 7.28 ) The data file named deere3 contains 57 consecutive values froma complex machine tool at Deere & Co. The values given are deviations from a target value in units of tenmillionths of an inch. The process employs a control mechanism that resets some of the parameters of themachine tool depending on the magnitude of deviation from target of the last item produced. Load the TSApackage and then use data(deere3) to load the data.1. Plot the data. Does it appear stationary?2. Plot the ACF and PACF for the data. Which values for ARMA(p, q) are suggested?53. Estimate the parameters of an AR(1) model for this series using maximum likelihood. Repeat this foran AR(2) model. Report the estimates, their standard errors, and the AIC values.4. Simulate from both fitted models using the estimated parameters, with n = 57. Plot the simulateddata for both models, and compare them to the original data.5. Using your observations from parts (3) and (4), which of AR(1) or AR(2) would you prefer and why?Question 13The data in sheep.dat are the sheep population (in millions) for England and Wales from 1867-1939. It canbe read into R with the commandsheep=ts(scan(‘sheep.dat’),start=1867)1. Plot the time series.2. Perform any transforms, take differences, and/or remove mean structure via regression to produce astationary series.3. Plot diagnostics from removing mean structure.4. Produce plots of the ACF and PACF of the stationary series.5. Justify a preliminary order of ARMA model.6. Fit the model, simulate from it, and compare with the data.7. Perform model diagnostics: calculate the residuals, check them for normality, and their ACF forremaining time series structure. Apply the Ljung-Box test.8. Make any adjustments to your model suggested by residuals diagnostics.9. State your final model, and include 1-2 sentences of justification.Question 14Please calculate the auto correlation function ρ(h) of Xt, where Xt comes from the following model.Xt = 1.4Xt−1 − 0.48Xt−2 + Wt − 0.2Wt−1 − 0.48Wt−2where Wt is a Gaussian white noise with variance σ2.Question 15In this question, after fitting a linear model, The model diagnostics plots are presented in Figure 1.Based on this diagnostic plot, what kind of model you will suggest to try? Please state your reason forselecting this model.6Figure 1: Diagnostic of the model7转自:http://www.daixie0.com/contents/18/4950.html
讲解:R、data、RMatlab|SQL
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- This is a pre-print version. Official version: http://rsi...