Assignments: Going forward, must submit rendered pdf of code portion. (if you want to be nice to me, do this for Assignment 2, but starts with Assignment 3)
Late quizzes: Going forward: Email me ahead of time, otherwise it’s a 0
Exam details: No use of computer, code will be covered but basic, notes sheet is allowed, practice test will be provided
Activity 1: Export Price of Salmon (Example 3.1)
Code
library(astsa)summary(fit <-lm(salmon~time(salmon), na.action=NULL))## ## Call:## lm(formula = salmon ~ time(salmon), na.action = NULL)## ## Residuals:## Min 1Q Median 3Q Max ## -1.69187 -0.62453 -0.07024 0.51561 2.34959 ## ## Coefficients:## Estimate Std. Error t value Pr(>|t|) ## (Intercept) -503.08947 34.44164 -14.61 <2e-16 ***## time(salmon) 0.25290 0.01713 14.76 <2e-16 ***## ---## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1## ## Residual standard error: 0.8814 on 164 degrees of freedom## Multiple R-squared: 0.5706, Adjusted R-squared: 0.568 ## F-statistic: 217.9 on 1 and 164 DF, p-value: < 2.2e-16tsplot(salmon, col=4, ylab="USD per KG", main="Salmon Export Price")abline(fit)
Activity 1: Export Price of Salmon (Example 3.1)
Does this time series appear stationary?
The (mathematical) equation in the book for the trend line above is:
The typo is the second year, it should be\(2003\frac{9}{12}\)
Why are there fractions of the year? Explain what the fractional values mean and describe how they appear in the data set within R.
Note that we are dividing by 12, so the fractions represent the months. Based on the values of time(salmon), January corresponds to\(\frac{0}{12}\), so for example September is represented as\(\frac{8}{12}\).
Interpret the estimate of the slope.
Each year, the expected export price of Norwegian salmon increases by 0.2592 USD per kg
Each month, the export price of Norwegian salmon increases by 0.2592/12 USD per kg on average
Activity 2: Trend Stationarity (Example 2.19)
Consider the time series model \[x_t = \beta t + y_t\] Assume \(y_t\) is stationary with mean function \(\mu_y\) and and autocovariance function \(\gamma_y(h)\)
Compare this equation to the regression equation in the last example.
What are the mean function and autocovariance function of \(x_t\)?
Consider the time series model \[x_t = \beta t + y_t\] Assume \(y_t\) is stationary with mean function \(\mu_y\) and and autocovariance function \(\gamma_y(h)\)
Compare this equation to the regression equation in the last example.
The equations are similar, with \(x_t\) being the same, \(\beta_1 = \beta\), \(\beta_0 = 0\), and \(w_t = y_t\), and \(z_t = t\). - What are the mean function and autocovariance function of \(x_t\)?
No, just pairwise with \(x_8\). We could do all possible pairs:
Distribution of all the correlations:
3D plots
3D version of histogram (includes \(s-t\) plane)
Simulated auto correlation function \(\hat{\gamma}_x(h)\) (with a blanket)
Theoretical \(\hat{\gamma}_x(h)\) (using the derived formula (with a blanket)
Detrending
Detrending
If a process is trend stationary (nonstationary in the mean, but stationary in the variance), can we just subtract off the trend and get back a stationary time series?
Yes, and that’s called detrending
Activity 3: Detrending a commodity (Example 3.7)
Given the code to generate the plot with the trend line, how would you view the equation of the trend line?
Visualize the de-trended series
Compute the acf of the salmon series and the detrended series. What do you notice?
Activity 3 Solution: Detrending a commodity (Example 3.7)
Given the code to generate the plot with the trend line, how would you view the equation of the trend line?
Visualize the de-trended series
Call:
lm(formula = salmon ~ time(salmon), na.action = NULL)
Residuals:
Min 1Q Median 3Q Max
-1.69187 -0.62453 -0.07024 0.51561 2.34959
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -503.08947 34.44164 -14.61 <2e-16 ***
time(salmon) 0.25290 0.01713 14.76 <2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.8814 on 164 degrees of freedom
Multiple R-squared: 0.5706, Adjusted R-squared: 0.568
F-statistic: 217.9 on 1 and 164 DF, p-value: < 2.2e-16
Detrending a commodity (Example 3.7)
Compute the acf of the salmon series and the de-trended series
Next time
Cross-correlation and regression with multiple time series (\(x_t\) on x-axis instead of \(t\) on x-axis like with the salmon) (Activities at the end of Ch 2)