Problem 3

Consider the local level model for annual flow on river Nile from class.

(a) Modify and re-estimate the model (without missing observations) so that it includes a dummy variable dam taking value 0 before the Aswan Dam was built in 1989, and value 1 afterwards. Hint: See the analysis for seas belt data we discussed in class, and in particular the way dummy variable law is included in that model.

## Call:
## SSModel(formula = Nile ~ SSMtrend(1, Q = list(matrix(NA))) + 
##     Dam, data = nile, H = matrix(NA))
## 
## State space model object of class SSModel
## 
## Dimensions:
## [1] Number of time points: 100
## [1] Number of time series: 1
## [1] Number of disturbances: 1
## [1] Number of states: 2
## Names of the states:
## [1]  Dam    level
## Distributions of the time series:
## [1]  gaussian
## 
## Object is a valid object of class SSModel.

(b) Create a plot with actual vs Kalman filtered data, and a second plot with actual vs Kalman smoothed data. How do they compare to the case without dam variable?

When we compare the plots of the state space model that uses the dummy variable for the presence of a dam versus none, we see that including the dam variable improves both the filtered and smoothed versions.

(c) Introduce missing data the same way we did it in class - replace observations 25:50 (years 1891 to 1920) and 71:80 (years 1941 to 1950) by NAs. Reestimate the model with missing data and create again the two plots from (b): one with actual vs Kalman filtered data, and one with actual vs Kalman smoothed data. How do the filtered and smoothed series differ for the period of missing data that includes the structural break to to dam construction (years 1891 to 1920)?

## Call:
## SSModel(formula = eNile[, 1] ~ SSMtrend(1, Q = list(matrix(NA))) + 
##     eNile[, 2], data = eNile, H = matrix(NA))
## 
## State space model object of class SSModel
## 
## Dimensions:
## [1] Number of time points: 100
## [1] Number of time series: 1
## [1] Number of disturbances: 1
## [1] Number of states: 2
## Names of the states:
## [1]  eNile[, 2]  level     
## Distributions of the time series:
## [1]  gaussian
## 
## Object is a valid object of class SSModel.

In the above plots, we do indeed see an improvement in the was the state space model can deal with missing data that includes the dummy variable versus the model without. In this “improved” model we see that our ci’s do not diverge as they do in the model that does not include the dam variable with missing data.