Elmously, Ziad (TSHHM)
2018-Mar-26 06:51 UTC
[R] "dlm" Package: Calculating State Confidence Intervals
To Whom It May Concern, I estimated a model with 6 states (3 time-varying Regression parameters and 3 quarterly seasonality trends). The model is saved in the object titled "mod." Following the example in the documentation and using the commands below, I am attempting to use the function "dlmSvd2var" to implement SVD and calculate the 90% confidence errors for each time-varying state. outF <- dlmFilter(y,mod) v <- unlist(dlmSvd2var(outF$U.C, outF$D.C)) pl <- dropFirst(outF$m) + qnorm(0.05, sd=sqrt(v[-1])) pu <- dropFirst(outF$m) + qnorm(0.95, sd=sqrt(v[-1])) Since the dataset has 100 observations, I end up with a vector v that comprises 3636 atomic components: (1 + 100) x (6 x 6). If I discard the 1st 36 of them, then v comprises 3600 atomic components. The question is how to extract the variance of each state (6 states) in the 36 atomic components representing each time (1:100). Said differently, how do I extract the variance of each state (6 states) in the 6 x 6 matrix generated by the "dlmDvd2var" function in time t? Is this information provided in the diagonal elements, element (1,1) for state 1, element (2,2) for state 2, and so on? Thank you in advance. Ziad Elmously Kantar Disclaimer<http://www.kantar.com/disclaimer.html> [[alternative HTML version deleted]]