[R] "dlm" Package: Calculating State Confidence Intervals

Elmously, Ziad (TSHHM) ziad.elmously at kantar.com
Mon Mar 26 08:51:36 CEST 2018


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]]



More information about the R-help mailing list