Usetutoringspotscode to get 8% OFF on your first order!

  • time icon24/7 online - support@tutoringspots.com
  • phone icon1-316-444-1378 or 44-141-628-6690
  • login iconLogin

Time Series (Statistics)

Time Series (Statistics)

I need a solution for a time series problem.

Only one problem and this one requires R using.

Problem is beloew :

In the R package astsa there is a data set called flu which gives the number of deaths per 10,000 people in the United States due to pneumonia and influenza. The data is recorded by month for 1968-1978. There is a slight trend so remove it by fitting a polynomial of order 1. Now fit a seasonal component to the detrended data using a sum of harmonics. Show the plots of the detrended data, the estimated seasonal component, and the residuals after the trend and seasonal components have been removed. You do not have to fit a model to the residuals. Give the values of asj , acj , and ?j that you used in your final model.

You can leave a response, or trackback from your own site.

Leave a Reply

Time Series (Statistics)

Time Series (Statistics)
The cmort dataset contains the average weekly cardiovascular mortality in Los Angeles County for 1970-1979. The data for the last year (1979) is only for the first 40 weeks. Therefore, we will analyze the data for 1970-1978. We can get this data using the following R code:
library(astsa)
x = as.vector(cmort[1:468])
t = as.vector(time(cmort)[1:468])
plot(t, x, type=”l”)
We will remove the seasonal component from the data using the moving average technique.
First choose an appropriate value of the period d and find the pre-estimate of mt . Plot the observed series in gray and show the pre-estimate on the same plot but in black (be sure to plot your time series using the type = “l” command).
Now find the estimate of st and plot these estimates for all t = 1, . . . , 468.
Find the residuals after removing the seasonal component and plot them.
Comment on whether you think these residuals look stationary or not. If they do not look stationary, what should we do to make them “look” stationary?
require(datasets)
X = as.vector(USAccDeaths)
t = 1:length(X)
plot(USAccDeaths, type = “o”, ylab = “Accidental Deaths”, col=”darkgray”)
mav.even <- function(x,d=12){filter(x,c(0.5/d,rep(1/d,(d-1)),0.5/d), sides=2)}
lines(as.vector(time(USAccDeaths)),mav.even(X), col = “black”)
x = X – mav.even(X)
w = unname(tapply(x, (seq_along(x)) %% 12, function(a) mean(a,na.rm = T)))
w = w-mean(w)
s = rep(w, 6)

plot(as.vector(time(USAccDeaths)), s, type = “o”, ylab = “”, xlab = “”)
d = X – s
plot(as.vector(time(USAccDeaths)), d, type = “o”, ylab = “”, xlab = “”)

t = as.vector(time(USAccDeaths))
w1 = t
w2 = t^2
fit = lm(d ~ w1+w2)
lines(t, fitted(fit), type = “l”)

plot(t,residuals(fit), type = “o”, ylab = bquote(hat(Y)[t]))

Responses are currently closed, but you can trackback from your own site.

Comments are closed.

Time Series (Statistics)

Time Series (Statistics)
The cmort dataset contains the average weekly cardiovascular mortality in Los Angeles County for 1970-1979. The data for the last year (1979) is only for the first 40 weeks. Therefore, we will analyze the data for 1970-1978. We can get this data using the following R code:
library(astsa)
x = as.vector(cmort[1:468])
t = as.vector(time(cmort)[1:468])
plot(t, x, type=”l”)
We will remove the seasonal component from the data using the moving average technique.
First choose an appropriate value of the period d and find the pre-estimate of mt . Plot the observed series in gray and show the pre-estimate on the same plot but in black (be sure to plot your time series using the type = “l” command).
Now find the estimate of st and plot these estimates for all t = 1, . . . , 468.
Find the residuals after removing the seasonal component and plot them.
Comment on whether you think these residuals look stationary or not. If they do not look stationary, what should we do to make them “look” stationary?
require(datasets)
X = as.vector(USAccDeaths)
t = 1:length(X)
plot(USAccDeaths, type = “o”, ylab = “Accidental Deaths”, col=”darkgray”)
mav.even <- function(x,d=12){filter(x,c(0.5/d,rep(1/d,(d-1)),0.5/d), sides=2)}
lines(as.vector(time(USAccDeaths)),mav.even(X), col = “black”)
x = X – mav.even(X)
w = unname(tapply(x, (seq_along(x)) %% 12, function(a) mean(a,na.rm = T)))
w = w-mean(w)
s = rep(w, 6)

plot(as.vector(time(USAccDeaths)), s, type = “o”, ylab = “”, xlab = “”)
d = X – s
plot(as.vector(time(USAccDeaths)), d, type = “o”, ylab = “”, xlab = “”)

t = as.vector(time(USAccDeaths))
w1 = t
w2 = t^2
fit = lm(d ~ w1+w2)
lines(t, fitted(fit), type = “l”)

plot(t,residuals(fit), type = “o”, ylab = bquote(hat(Y)[t]))

Responses are currently closed, but you can trackback from your own site.

Comments are closed.

Powered by WordPress | Designed by: Premium WordPress Themes | Thanks to Themes Gallery, Bromoney and Wordpress Themes